Iam getting the  TypeError: Unable to get property 'then' of undefined or 
null reference when try to use the below code.

var app = angular.module(,$scope,['tableSort']);
   //Get All the Dash Board Services
   app.factory('ResourceDetailsFactory', function ($http) {
       return {
           GetResources: function (ResourceType, Status) {
               //since $http.get returns a promise,
               //and promise.then() also returns a promise
               //that resolves to whatever value is returned in it's 
               //callback argument, we can return that.
               $http.post('dummay.aspx/Getmethod', { resource: 
ResourceType, status: Status }).then(function (result) {
                             return result.data;
               });
           }
       }
   });
 ResourceDetailsFactory.GetResources(ResourceType, Status).then(function 
(data) {
         
        });

Any one can help me what wrong in the 
ResourceDetailsFactory.GetResources(ResourceType, Status).then(function 
(data) {}

Thanks
Sudhakar

----------------------------------------------------------------------------------------------------------------------------------

On Tuesday, 9 September 2014 00:21:09 UTC+5:30, mark goldin wrote:
>
> Service:
> var myModule = angular.module('myApp', []);
>
> myModule.factory("AirportService", function ($http, $q) {
>
>     return {
>         getData : function(){
>             var deferred = $q.defer();
>             var response = $http.get("griddata.json");
>             response.success(function (data) {
>                 deferred.resolve(data);
>             });
>             response.error(function (data) {
>                 alert('Error 123');
>             });
>             // Return the promise to the controller
>             return deferred.promise;
>         }
>     }
> });
>
> Controller:
> var myModule = angular.module("myApp", []);
> myModule.controller('AirportControllers', [function ($scope, $http, 
> AirportService) {
>     AirportService.getData().then(function(data) {
>         $scope.agents = data;
>     });    
> }]);
>
> No matter what I do I get:
> TypeError: Unable to get property 'getData' of undefined or null reference
>  at Anonymous function (http://..../angular/controllers.js:3:5)
>
> Any idea?
>
> Thanks
>

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