AngularJS错误.success不是函数 [英] AngularJS error .success is not a function
本文介绍了AngularJS错误.success不是函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经建立了一个工厂来处理我的控制器的功能,但是不知何故,控制器在其中一个功能上返回了错误:
I have build a factory to handle the functions for my controller, but somehow the controller returns an error on one of the functions:
错误:Auth.getUser(...).成功不是一个函数 @ http://localhost:8080/app/controllers/mainCtrl.js:10: 1
...
Error: Auth.getUser(...).success is not a function @http://localhost:8080/app/controllers/mainCtrl.js:10:1
...
我不知道这是怎么回事,其余功能似乎运行正常?
I have no idea what's going on here, the rest of the functions seem to be working fine?
主控制器:
angular.module('mainCtrl', [])
.controller('mainController', function($rootScope, $location, Auth) {
var vm = this;
vm.loggedIn = Auth.isLoggedIn();
$rootScope.$on('$routeChangeStart', function() {
vm.loggedIn = Auth.isLoggedIn();
Auth.getUser()
.success(function(data) {
vm.user = data;
});
});
vm.doLogin = function() {
Auth.login(vm.loginData.username, vm.loginData.password)
.success(function(data) {
$location.path('/users');
});
};
});
推荐答案
查看全文