我試圖讓一個回調函數在一個Angular $ http 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?');
});
};
}]);
您是否收到任何控制檯錯誤? – Vineet
沒有錯誤。該帖子的作品。只是不是回調 – nickg
添加'.catch(function(){console.log(arguments);});',並在$ http.post行添加一個斷點。任何結果? –