我有这个代码,我已经做了一个刷新功能,明确说明了目的。我也必须刷新其他统计数据,但我无法在"刷新"内部调用它。功能如下,即使它们在相同范围内。我确信我正在调用它,但是控制台一直给出以下错误:
ReferenceError:未定义getAllCustomers
$scope.getAllCustomers = new function(){
$http.post('
<?php echo site_url('angularjs/get_users_by_type/'); ?>',
{userType:'C'}).then(function(response) {
$scope.totalCustomer = response.data.count;
}, function(response) {
console.log(response);
// called asynchronously if an error occurs
// or server returns response with an error status.
});
};
// getAllCustomer etc all defined before this function but the following errors keeps coming on the console that getAllCustomers is not a function.
$scope.refresh = new function(){
getAllCustomers();
};
答案 0 :(得分:3)
在声明功能时删除new
关键字,应该是
$scope.getAllCustomers = function()
答案 1 :(得分:1)
检查你的代码:
$scope.getAllCustomers = function(){
$http.post('
<?php echo site_url('angularjs/get_users_by_type/'); ?>',
{userType:'C'}).then(function(response) {
$scope.totalCustomer = response.data.count;
}, function(response) {
console.log(response);
});
};
$scope.refresh = function(){
$scope.getAllCustomers();
};