angularjs - Error: $injector:unpr Unknown Provider -
i trying make share service using following code:
whoisapp.service('sharedscope',function($scope){ this.domainname="google.com"; }); whoisapp.controller('maincontroller',function($scope,sharedscope){ $scope.$watch('domainname',function(){ sharedscope.domainname=$scope.domainname; }); });
the problem is, when run application, face error in console:
error: $injector:unpr unknown provider
it seems little strange since have defined sharedscope
service. wrong code?
update:
here definition of app:
var whoisapp=angular.module('whoisapp',['ngroute','ngresource']); whoisapp.config(function($routeprovider){ $routeprovider .when("/",{ templateurl:'home.html', controller: 'maincontroller' }) });
there error in function parameters, should this:
whoisapp.controller('maincontroller',function($scope, sharedscope){..
Comments
Post a Comment