我有一个名为“ TRK_9_1_upgrade”的按钮,用于启动进程(TRK_9_1_upgrade = 1),该进程已启动的信号来自(TRK_9_1_master_control_enabled = 0),我需要在该信号到达TRK_9_1_upgrade的值时变为0。
我尝试了以下代码,但不能正常运行,如何实现正确的行为?
<ma-switch-img point="TRK_9_1_upgrade" ng-mousedown="TRK_9_1_upgrade.setValue(!TRK_9_1_upgrade.value)" ng-mouseup="TRK_9_1_upgrade.setValue(TRK_9_1_master_control_enabled.value && TRK_9_1_upgrade.value)" default-src="./img/emergency-tiny.png" src-map="{'0': './img/off-tiny.png','1': './img/on-tiny.png'}">
答案 0 :(得分:0)
这是我的解决方案:
<md-button ng-if="TRK_9_1_master_control_enabled.value==1" ng-init="TRK_9_1_upgrade.setValue(0)" ng-click="TRK_9_1_upgrade.setValue(1)" class="md-raised" title="Upgrade">Upgrade</md-button>
<md-button ng-if="TRK_9_1_master_control_enabled.value==0 && TRK_9_1_upgrade.value==1" class="md-raised md-pressed" title="Upgrading">Upgrading</md-button>
我认为还可以,因为在第一次满足条件时使用ng-if,也称为ng-init。