You are God Send....Thanks a lot...:)

On Wednesday, September 12, 2012 8:53:33 PM UTC+4, Uri Goldshtein wrote:
>
> Hi,
>
>    I've created a service that calls $http (not $resource) and to get the 
> value to the controller.
>    It took some time and i found a lot of example but not exactly what i 
> needed. 
>    Maybe this will help someone:
>
>    The service:
>
> angular.module('myApp.services', []).
>     service('Activities', function($http, $q) {
>         this.get = function(from, to){
>             var deferred = $q.defer();
>             var url = 'user/activities?from='+from+'&to='+to;
>             $http.get(url).success(function(data, status) {
>                 // Some extra manipulation on data if you want...
>                 deferred.resolve(data);
>             }).error(function(data, status) {
>                 deferred.reject(data);
>             });
>
>             return deferred.promise;
>         }
>     }
> );
>
>
> The call inside the controller (don't forget to DI the service in the 
> controller's parameters):
>
>     var promise = Activities.get(now, monthAgo);
>     promise.then(
>         function(activities){$scope.transactions = activities;}
>         ,function(reason){alert('Failed: ' + reason);}
>      );
>
>
>

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