Hi guys, i'm using $http.get functiosn in every controllers but i now want
to simplify it by writing my function once and using it in every controller.
I tried something but it seems it's not working.
.factory('FactoryName', function($scope, $routeParams, $http) {
return {
search : function(str) {
var url = str+'.json';
return $http.get(url);
};
};
.controller('CtrlName', ['$scope', '$routeParams', '$http',
'FactoryName'function($scope, $routeParams, $http, FactoryName) {
FactoryName.search("myJson").then(function(data){
$scope.myData = data;
}).error() {blabla
Do you have any ideas ? 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.