我已经构建了一个工厂来处理我的控制器的功能,但不知何故控制器在其中一个函数上返回错误:
错误:Auth.getUser(...).成功不是函数@ http:// localhost:8080/app/controllers/mainCtrl.js:10:1
...
我不知道这里发生了什么,其余的功能似乎工作得很好?
主控制器:
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');
});
};
});
Run Code Online (Sandbox Code Playgroud)
Dev*_*per 15
这是代码
已删除的代码
$http(
{
method: 'POST',
url: '/Home/CreateCustomer', /*You URL to post*/
data: $scope.cust /*You data object/class to post*/
}).success(function (data, status, headers, config)
{
}).error(function (data, status, headers, config)
{
});
Run Code Online (Sandbox Code Playgroud)
允许的代码 Angular $ http docs
$http(
{
method: 'POST',
url: '/Home/CreateCustomer', /*You URL to post*/
data: $scope.cust /*You data object/class to post*/
}).then(function successCallback(response) {
// this callback will be called asynchronously
// when the response is available
}, function errorCallback(response) {
// called asynchronously if an error occurs
// or server returns response with an error status.
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
62387 次 |
| 最近记录: |