我有一个非常简单的 ng-if 构造,它使用两个 MD 按钮和一个 AngularJS 范围变量isPlaying
。但是,ng-if 似乎不能与变量一起使用。当我使用控制台工具单击按钮时,我可以看到变量发生变化,但是 DOM 没有变化。奇怪的是,当我悬停其他 Angular 组件(例如主导航中的按钮)时,ng-if 似乎确实会触发。
HTML/MD/PHP:
<md-button class="md-icon-button" ng-if="!isPlaying" ng-click="play()" aria-label="Play">
<md-icon md-svg-src="<?php echo get_stylesheet_directory_uri(); ?>/img/icon/ic_play_arrow_black_24px.svg"></md-icon>
</md-button>
<md-button class="md-icon-button" ng-if="isPlaying" ng-click="pause()" aria-label="Pause">
<md-icon md-svg-src="<?php echo get_stylesheet_directory_uri(); ?>/img/icon/ic_pause_black_24px.svg"></md-icon>
</md-button>
JS:
$scope.play = function () {
player.playVideo();
$scope.isPlaying = true;
}
$scope.pause = function () {
player.pauseVideo();
$scope.isPlaying = false;
}