.controller('LoginCtrl', function($scope, $location, $stateParams, $ionicHistory, $http, $state, $auth,$rootScope) {
$scope.loginForm = {}
$scope.loginError = false;
$scope.loginErrorText;
$scope.login = function() {
var credentials = {
email: $scope.loginForm.email,
password: $scope.loginForm.password
}
console.log(credentials);
$auth.login(credentials).then(function() {
$http.get('http://localhost:8000/api/authenticate/user').success(function(response){
var user = JSON.stringify(response.user);
localStorage.setItem('user', user);
$rootScope.currentUser = response.user;
$ionicHistory.nextViewOptions({
disableBack: true
});
$state.go('app.jokes');
})
.error(function(){
$scope.loginError = true;
$scope.loginErrorText = error.data.error;
console.log($scope.loginErrorText);
})
});
}
}); 我收到此错误错误:[$injector:unpr] Unknown provider: $authProvider <- $auth <- LoginCtrl当我在函数中添加 $auth 时。