angularjs service error [$interpolate:interr] Can't interpolate: Factory -


i writing factory/service first time , trying image factory controller getting undefined when in factory function reason.

here fiddle https://jsfiddle.net/vijay_vadlamani/2ql2lh5r/1/ html:-

js:-

angular.module('myapp').factory('imagefactory', function() { return function contentimage($scope) {     $scope.getimage = function(content) {     return getcontentimage(content); }; 

}; });

angular.module(myapp).controller('getimagectrl', ['$scope', 'imagefactory', function($scope, imagefactory) { $scope.getlistimage = function(content) {     return imagefactory.getimage(content); }; 

}]);

try declare service this:

var app = angular.module('myapp',[]); app.factory('imagefactory', function()  {   var service =    {     getimage: function(content)      {       return getcontentimage(content);      }   };   return service }); 

and use this:

app.controller('getimagectrl', ['$scope','imagefactory',function($scope, imagefactory)  {   $scope.getlistimage = function(content)    {     return imagefactory.getimage(content);    }; }]); 

here's demo


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -