可以使用Angular的$apply方法来强制更新视图。在请求完成后,使用$timeout或$apply方法来触发更新。
示例代码:
$http.get('yourUrl')
.then(function(response) {
$timeout(function() {
$scope.variable = response.data;
});
});
或者使用$apply方法:
$http.get('yourUrl')
.then(function(response) {
$scope.$apply(function() {
$scope.variable = response.data;
});
});
上一篇:Angular变量不更新