我只是想知道如何以及在哪里可以使用$ watch更新我使用带有缓存的http get请求收到的数据:true option.i刚开始使用angular。
服务:
app.factory('customer', ['$http',function($http){
var obj = {};
var baseUrl="../controller/customer.php";
obj.fetchCustomers= function(){
var config={
cache: true
}
return $http.get(baseUrl +'?type=getAll',config);
}
obj.editCustomer=function(customerInfo){
return $http.post(baseUrl,{data:customerInfo ,type:'edit'});
}
return obj;
}]);
接收数据的控制器:
customer.fetchCustomers().success(function(data){
$rootScope.customers=data.getAll;
})
编辑数据的控制器:
$scope.editCustomer=function(){
customer.editCustomer($scope.customerInfo).success(function(data){
if(data.error=true){
$location.path("/accounting/viewCustomer");
}else{
$scope.alert="wrong";
}
})
};
它工作正常但我的观点在更新数据时不会更新