Sunday, 15 January 2012

javascript - Angularjs Unknown provider error -



javascript - Angularjs Unknown provider error -

i getting

error: [$injector:unpr] unknown provider: mvprofilectrlprovider <- mvprofilectrl

in error, have made sure included in scripts , accessible ( can open chrome-debugger > sources > mvprofilectrl.js ) available referencing guess. still here 2 relevant files:

angular.module('app').controller('navbarlogincontroller',function($scope,$http,mvidentity,mvnotifier,mvauth,mvprofilectrl,$location) { $scope.identity = mvidentity; $scope.signin = function(username,password) { mvauth.authenticateuser(username,password).then(function(success){ if(success){ mvnotifier.notify('you have signed in!'); }else{ mvnotifier.notify('username/password combination incorrect'); } }) } var profile = mvprofilectrl; $scope.update = function(){ profile.listen(mvidentity.currentuser); } $scope.signout = function() { mvauth.logoutuser().then(function() { $scope.username = ""; $scope.password = ""; mvnotifier.notify('you have signed out!'); $location.path('/'); }) } })

and mvprofilectrl.js -

angular.module('app').controller('mvprofilectrl', function($scope, mvauth, mvidentity, mvnotifier) { $scope.mvidentity = mvidentity; $scope.update = function() { console.log("" + $scope.updateemail + " -- " + test); var newuserdata = { username: $scope.updateemail, firstname: $scope.updatefname, lastname: $scope.updatelname } if($scope.updatepassword && $scope.updatepassword.length > 0) { newuserdata.password = $scope.updatepassword; } mvauth.updatecurrentuser(newuserdata).then(function() { $('#profilemodal').modal('toggle'); mvnotifier.notify('your user business relationship has been updated'); }, function(reason) { mvnotifier.error(reason); }) } homecoming { hear : function(currentuser) { if (!currentuser) return; $scope.updateemail = currentuser.username; $scope.updatefname = currentuser.firstname; $scope.updatelname = currentuser.lastname; console.log("--> " + $scope.updateemail + " -- " + test); } } });

and scripts file -

script(type="text/javascript", src="/vendor/jquery/dist/jquery.js") script(type="text/javascript", src="/vendor/toastr/toastr.js") script(type="text/javascript", src="/vendor/angular/angular.js") script(type="text/javascript", src="/vendor/angular-resource/angular-resource.js") script(type="text/javascript", src="/vendor/angular-route/angular-route.js") script(type="text/javascript", src="/vendor/bootstrap/dist/js/bootstrap.js") script(type="text/javascript", src="/vendor/bootstrap/js/dropdown.js") script(type="text/javascript", src="/app/app.js") script(type="text/javascript", src="/plugins/backstretch/jquery.backstretch.min.js") script(type="text/javascript", src="/plugins/bxslider/jquery.bxslider.min.js") script(type="text/javascript", src="/plugins/bxslider/jquery.bxslider.min.js") script(type="text/javascript", src="/app/account/navbarlogincontroller.js") script(type="text/javascript", src="/app/common/mvnotifier.js") script(type="text/javascript", src="/app/account/mvidentity.js") script(type="text/javascript", src="/app/account/mvauth.js") script(type="text/javascript", src="/app/account/mvuser.js") script(type="text/javascript", src="/app/admin/mvuserlistctrl.js") script(type="text/javascript", src="/app/account/mvsignupctrl.js") script(type="text/javascript", src="/app/account/mvprofilectrl.js")

the issue here is, trying inject controller controller. , that's not how should be.

please check the:

can 1 controller phone call in angularjs?

to see, how should communicate among controllers - using shared service.

the biggest difference between services , controllers (see developer guide / dependency injection ):

controllers special in that, unlike services, there can many instances of them in application. example, there 1 instance every ng-controller directive in template.

so, when trying phone call methods of 1 controller within of other 1 ... should move singleton service

javascript angularjs

No comments:

Post a Comment