ユーザーが正常にログインしたかどうかにかかわらず、ログインプロセス中にユーザーに警告するためにnotifier
使用するというサービスを作成しました。toastr
これが私のログインモジュールです:
var login = angular.module('login',[]);
login.controller('mvLoginCtrl', function($scope, $http){
$scope.signin = function(username, passowrd){
$http.post('/login', {username:username, passowrd:passowrd}).then(function(response){
if(response.data.success){
mvNotifier.notify('You have successfully signed in!');
}else{
mvNotifier.notify('Username/Password combination incorrect');
}
})
}
})
ここまでエラーは発生しませんでしたが、サインインしようとすると、次の明らかなエラーが発生します。
ReferenceError: mvNotifier が定義されていません
必要な依存関係を含む 2 行目のログイン モジュールを変更しました。
login.controller('mvLoginCtrl', function($scope, $http, mvNotifier)
しかし、その後、別のエラーが発生しました
エラー: [$injector:unpr] http://errors.angularjs.org/1.2.20/ $injector/unpr?p0=mvIdentityProvider%20%3C-%20mvIdentity
このエラーが発生した理由とその解決方法をお聞きしたいと思います。ここに私の mvNotifier モジュールコードがあります:
var notifier = angular.module('notifier', []);
notifier.value('mvToastr', toastr);
notifier.factory('mvNotifier', function(myToastr){
return{
notify: function(msg){
mvToastr.success(msg);
console.log(msg);
}
}
})
ありがとうございました。