我有一个看起来像这样的角度函数。
function request($scope, $http) {
$http.get("http://www.w3schools.com/angular/customers.php")
.success(function (response) {
$scope.names = response.records;
});
}
我喜欢用常规函数替换匿名函数只是为了摆脱丑陋的缩进。我不确定我在做什么,因为我没有太大的成功。基本上,我喜欢看起来像这样。
function request($scope, $http) {
processGoodStatus = function (response) {
$scope.names = response.records;
}
$http.get("http://www.w3schools.com/angular/customers.php")
.success(processGoodStatus);
}
怎么会这样呢?谢谢你的帮助。
答案 0 :(得分:0)
您忘记使用var
像这样声明
var processGoodStatus = function (response) {
$scope.names = response.records;
}