私の.run
ブロックにサービスを注入したいのですが、注入すると使えません。角度のjsで.runでサービスを挿入できません
私のコードは次のとおりです。
.run(['AuthFactory', function ($state, $rootScope, AuthFactory, $location) {
console.log("Auth Factory :%O", AuthFactory);
AuthFactory.registerUserChangeHandler(function (currentUser) {
$rootScope.currentUser = currentUser;
});
AuthFactory.refresh().then(function (currentUser) {
console.log("Current User is", currentUser);
}, function (reason) {
// User is not Logged in
$location.path("login");
});
}]);
私はこのコードを書くとき、私はエラーを取得する:私は単に機能でAuthFactory
を注入した場合
"app.js:120Uncaught TypeError: Cannot read property 'registerUserChangeHandler' of undefined"
は、すべてが正常に動作しますが、今はUserService
を注入したいです&サービス内のメソッドを使用します。
私は機能に注入しようとしましたが、使用できません。
すべての提案を開きます。