2016-05-02 7 views
0

悪い引数をAREQ:AngularJSエラー:ngの:私は、次の3つのangularjsスクリプト持っ

/config.js 
/authentication/LoginCtrl.js 
/authentication/loginFactoyr.js 

のApp ristoreAppはconfig.jsの中で定義されています。

angular.module('ristoreApp', []) 
.controller('LoginCtrl', ['$scope', '$location', 'loginFactory', function($scope, $location, loginFactory){ 
    $scope.authenticate = function() { 
     loginFactory.login($scope.username, $scope.password) 
     .then(function(response) { 
      console.log(response); 
      $location.path('/home'); 
     }, function errorCallBack(response) { 
      console.log(response); 
      $location.path('login'); 
     }); 
    } 
}]); 

がエラーガット:

//config.js

angular.module('ristoreApp', ['ngRoute']) 

.config(function ($routeProvider, $locationProvider, $httpProvider) { 
// $httpProvider.responseInterceptors.push('httpInterceptor'); 

    $routeProvider 
     .when('/login', { 
      templateUrl: 'authentication/login.html', 
      controller: 'LoginCtrl' 
     }) 
     .when('/home', { 
      templateUrl: 'home.html', 
     }) 
     .otherwise({ 
      redirectTo: '/login' 
     }); 

    $locationProvider.html5Mode(true); 
}); 

は私のコントローラは "angular.module" でアプリを呼び出す "エラー:NG:AREQ悪い引数"

Argument 'LoginCtrl' is not a function, got undefined 

私のコントローラーは機能ではないと言うのはなぜですか?私は何を間違えたのですか?

答えて

1

これを試してください。 LoginCtrlの引用符を削除します。私はどのような引用符を削除しますか

var LoginCtrl = app.controller("LoginCtrl", ["$scope", function($scope) { /* etc... */}]); 
+0

controller: LoginCtrl 

その後、としてコントローラを定義しますか?コントローラを 'app = angular.module( 'ristoreApp'、[])に変更しました。 var loginCtrol = app.controller( "LoginCtrl"、['$ scope'、... 'しかし助けにならなかったのですが) – ddd

+0

あなたは引用符を削除する必要があります: 'LoginCtrl''は' controller:LoginCtrl' – Kyle

関連する問題