2
我不知道爲什麼我的列表沒有更新,點擊了add
。它只在刷新時更新。這裏是我的代碼爲什麼我的列表只在刷新時更新
服務
function getCustomer() {
return $http.get(API_URL+'api/customer')
.then(getCustomerSuccess)
.catch(function(err) {
});
function getCustomerSuccess(response) {
return response.data;
}
}
的js
function getCustomer() {
dataServices.getCustomer()
.then(function(response){
vm.customer = response;
})
}
vm.add = function(customer) {
dataServices.addCustomer(customer);
getCustomer();
logger.success('Add Customer Success');
}
謝謝建議我會試試看。但是,你能解釋一下爲什麼在這種情況下應該使用$ q –
@NguyễnBảoDũng查看這個例子:http://jsfiddle.net/oymubx4z/ –
這不是工作。我正在嘗試使用不同的文件進行測試,它的工作原理。但在我的文件中,這是行不通的。我使用CORS,所以CORS與此相關或不相關? –