angularjs - Data in Angular Services/Controllers -


i load data in service , request data in controllers.

e.g.

angular.module "xyz"   angular.module("myrecipesservice", []).service "recipesservice", ($http) ->     self = @     @.recipes = []     @.getrecipesfromdatabase = () ->       return $http.get('/getproovenrecipes').then( (result) ->         #console.log result.data         self.recipes = result.data         return result.data     @.getrecipes = () ->       return @.recipes 

later request data service in diff. controller calling getrecipes.

angular.module "xyz"   .controller 'recipesctrl', ($scope, recipesservice) ->     $scope.filteredrecipes = recipesservice.getrecipes() 

does store copy of recipes in each controller? or there way directly reference data in service. remember c times, used lot of pointers, stored information find array.

as @.recipes not private variable of service, use : recipesservice.recipes this not watch changes within if recipesservice.recipes changes during controller life.


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -

How to provide Authorization & Authentication using Asp.net, C#? -