我想要的是当我单击一个按钮并在 2 秒后隐藏它时显示一个 DIV。
<div ng-show="alertMsg.show">{{alertMsg.text}}</div>
触发点击事件后,DIV正确显示,但无法隐藏。似乎“alertMsg.show”的值在 2 秒后已正确更改为 FALSE,但视图中仍然存在 DIV。
点击事件:
$scope.$apply(function(){
$scope.alertMsg.show = true;
});
$timeout(function () {
$scope.alertMsg.show = false;
}, 2000);
我想知道如何通过 $timeout 隐藏 DIV