Not able to call service in angularjs -
i getting following error:
error: [$injector:unpr] unknown provider: myserviceprovider <- myservice
while calling service in angularjs please me solve issue
var app = angular.module('app', []) app.controller('mycontroller', ['$scope', 'stringservice', function ($scope, stringservice) { $scope.output = stringservice.processstring(input); }]); var app = angular.module('app', []); app.factory('stringservice', function(){ return{ processstring: function(input){ if(!input){ return input; } var output = ""; for(var = 0; < input.length; i++){ if(i > 0 && input[i] == input[i].touppercase()){ output = output + " "; } output = output + input[i]; } return output; } } });
in:
['$scope', 'myservice', function ($scope, stringservice)
you injecting myservice
doesn't exist. so, change to:
['$scope', 'stringservice', function ($scope, stringservice)
Comments
Post a Comment