【发布时间】:2018-08-24 02:28:56
【问题描述】:
check()是从html中调用的,返回值应该是true/false。
ng-class="{'timeline-inverted: check(id)'}"
$scope.server.get() 从服务器脚本获取result(r),我需要将$scope.result 返回给check() 函数。
这是我的 Angular 代码:
$scope.check = _.memoize(function(userId) {
$scope.server.get({
action: 'checkif',
userID: userId
}).then(function successHandler(r) {
$scope.result = r.data.result;
});
return $scope.result; // $scope.result is undefined
});
【问题讨论】:
-
你的回报应该在.then你试过了吗?
-
@Fix3r 是的,不工作。
标签: javascript angularjs http get response