This is my custom EventData service:: 

eventsApp.factory('eventData', 
    function($resource, $q){  
        var resource = $resource('data/event/:id.json',{id:'@id'});
        return {
            getEvent: function(){
                var deferred = $q.defer();
                resource.get({id:1}, 
                            function(event){
                                deferred.resolve(event);
                            },
                            function(response){
                                deferred.reject(response);
                            }
                        );
                return deferred.promise;
            },
            save: function(event){
//                window.alert("Hello");
                var deferred = $q.defer();
//                event.id = 999;
                resource.save(event, 
                    function(response){
                        deferred.resolve(response);
                    },
                    function(response){
                        deferred.reject(response);
                    }
                );
                return deferred.promise;
            }
        }
    }
);

and this is my controller ::
eventsApp.controller('EventController',
    function($scope, eventData){
        $scope.sortorder = 'name'; 
        $scope.event = eventData.getEvent();
        
        $scope.event.then( 
            function(event){
                console.log(event);
            },
            function(response){
                console.log(response)
            }
        );
        
        $scope.upVoteSession = function(session){
            session.upVoteCount++;
        };
        
        $scope.downVoteSession = function(session){
            session.upVoteCount--;
        };
    }
);
 
But nothing shows in my view after using promise. otherwise it is good. 
ng-resource is added to the model
var eventsApp = angular.module('eventsApp',['ngResource']);

Did I make any mistake?

-- 
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