0
Ich habe die folgenden drei AngularJS Skripte:AngularJS Fehler: ng: areq Bad Argument
/config.js
/authentication/LoginCtrl.js
/authentication/loginFactoyr.js
App ristoreApp
in config.js definiert ist.
//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);
});
Mein Controller ruft die App von "angular.module":
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');
});
}
}]);
Haben Sie den Fehler "Fehler: ng: areq Bad Argument"
Argument 'LoginCtrl' is not a function, got undefined
Warum sagt mein Controller keine Funktion? Was habe ich falsch gemacht?
Welche Zitate entferne ich? Ich habe meinen Controller in 'app = angular.module ('ristoreApp', []) geändert; var LoginCtrol = app.controller ("LoginCtrl", ['$ scope', ... 'aber es hat nicht geholfen – ddd
Sie müssen die Anführungszeichen entfernen.' Controller: 'LoginCtrl' sollte 'controller: LoginCtrl' sein – Kyle