我想每10秒进行一次http调用,然后显示一个div,如果rootScope.mailSent等于true。通话很好。
在我的控制器中我已经做到了:
$interval(function(){
$http.get("/api/sentMails")
.then(function(response) {
if (response.data.length>0){
$rootScope.mailSent = true;
}
});
}.bind($rootScope), 10000);
笔者认为:
<div ng-show="{{mailSent === true}}" class="pastille" ng-cloak=""></div>
但DIV从来没有显示,而mailSent值为true。 我错过了什么吗?
你不需要'{{}}''中的NG-show'因为它接受一个表达式。 –
是否每次请求完成时都尝试console.log($ rootScope.mailSent)? –
是的@MuliYulzary是正确的,你不需要''{}}'在'ng显示' –