I am following 
https://github.com/StarterSquad/startersquad.github.com/tree/master/examples/angularjs-requirejs-2
 
folder structure in my app 

inside services i have added following code 

     define(['./module'], function(services) {
    'use strict';
    services.factory('CreditCard', ['$http', function($http) {

    function CreditCardFactory() {

        function parseMessage(message) {
            if (message.response) {
                return message.response;
            }
        }

        function CreditCard(value) {
            angular.copy(value || {}, this);
        }

        CreditCard.$get = function(id) {
            var value = this instanceof CreditCard ? this : new 
CreditCard();
            $http({
                method: 'GET',
                url: '/creditcards/' + id
            }).then(function(response) {
                var data = response.data;
                if (data) {
                    angular.copy(parseMessage(data), value);
                }
            });
            return value;
        };

        CreditCard.prototype.$get = function(id) {
            CreditCard.$get.call(this, id);
        };

        return CreditCard;

      }

    return CreditCardFactory;

    }]);
       

    });

i have followed this question and added above code in factory

http://stackoverflow.com/questions/12719782/angularjs-customizing-resource

in this question 
        app.controller('CreditCardCtrl', function($scope, CreditCard) {
          $scope.creditCard = CreditCard().get(3);
       });
CreditCard is added without adding dependency as we add defualt angular 
services like $scope and $http.

 if i dont add dependency 
               controllers.controller('myListCtrl',   
 
['Phone','Phone1','loginForm','$scope','$http','user_resources',function(Phone,Phone1,loginForm,$scope,$http,user_resources,CreditCard){
 then it gives undefined and if i add it in my controller as dependency and 
then try to call get function then response is not returned 

         controllers.controller('myListCtrl',   
 
['Phone','Phone1','loginForm','$scope','$http','CreditCard',function(Phone,Phone1,loginForm,userSrv,$scope,$http,user_resources,CreditCard){

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to