angularjs: Customizing resource -
I am following folder structure in my app
I added the following code within the services Use the (credit card), ['$ http', function ($ http) {function CreditCardFactory ()). {Function parseMessage (message) {if (message.response) {return message.response;}} function credit card (value) {angular.copy (value || {}, this);} credit card. $ Get = function (id) {var value = Credit card of this example? It: new credit card (); $ Http ({method: 'GET', url: '/ creditcards /' + id}) Then (function (response) {var data = response.data; if (data) {Angel copy (parsmessage (data), value);}}); Return value;} credit card. Prototype $ Get = function (id) {credit card. $ Get.call (this, id);}; Credit card return;} credit card factory;}]}}};
I have followed this question and have added the above code to the factory
In this question, the app.controller ('CreditCardCtrl' , Function ($ scope, credit card) {$ scope.creditCard = CreditCard (.) Get (3);}); Credit cards are added without dependence because we add defualt angular services to $ radius and $ http.
If I have a dependency control controller ('myListCtrl', ['phone', 'Phone1', 'loginForm', '$ Scope', '$ http', 'user_resources', function (phone, phone1 , Login form, $ radius, $ http, user_resources, credit card) {So it gives undefined and if I add it as a dependency in my controller and if you try to call the call when the function is received, the response is not sent.
Controller (Controller 'myListCtrl', ['Phone', 'Phone1', 'Login Form', '$ scope', '$ http', 'Credit Card' {
'credit card' has not been declared as dependency in this example, so it is not being injected and it is undefined ... Controller ('myListCtrl', ['Phone', 'Phone1', 'Login Form', '$ Scope', '$ http', 'user_resources', function (Phone, Phone1, Login Form, $ Scope, $ http, user_resources, CreditCard) { < / Pre> To fix this, add 'credit card' ... controllers.controller ('myListCtrl', ['phone', ' 'Phone1', 'Login form', '$ scope', '$ http', 'user_source', 'credit card', function (phone, phone1, login form, $ http, user_resources, credit card) { / Pre>
In the second example, some dependencies are missing, which can be done in the wrong order in comparison to the function arguments ...
Controllers. Controller ( 'MyListCtrl', ['Phone', 'Phone1', 'Login '$', '$ Http', 'credit card', function (phone, phone1, loginform, userSrv, $ scope, $ http, user_resources, credit card) << code> Add missing dependencies in the correct order ...
Controller Controller ('myListCtrl', ['Phone', 'Phone1', 'Login Form', 'User Server', '$ Scope ',' $ http ',' user_resence ',' credit card ', function (phone, phone1, long form, user sru), $ scope, $ http, user_source, credit card) {
Comments
Post a Comment