【发布时间】:2015-09-25 18:11:39
【问题描述】:
我正在尝试在 Angular $http Post 之后触发回调函数,但我没有运气。我的 Post 函数正在运行,但回调不起作用。我在 Angular 的网站上看到 .success() 已被弃用,所以我正在尝试 .then() 但这似乎也没有任何作用。
谁能告诉我我错过了什么?非常感谢您提前。
starwarsApp.controller('appController', ['$scope', '$http','$q', function($scope, $http,$q) {
$scope.addContact = function(){
$http.post('/jediList',$scope.jediEntered).then(function(response){
console.log('Why am I not being seen?');
});
};
}]);
【问题讨论】:
-
您是否收到任何控制台错误?
-
没有错误。该职位有效。只是不是回调
-
添加
.catch(function () {console.log(arguments);});,并在$http.post 行添加断点。有结果吗? -
'then' 方法有 2 个参数(第一个用于 'success' 方法,第二个用于 'error' 方法。不过我不确定这是不是原因。
标签: javascript angularjs post callback