0
作为AngularJS/Cordova/Ionic的新手我点击“Eingepasst”按钮可以实现不同的功能,与“Gewonnen”相比,或“Verloren”。由于在另一个线程中得到了帮助,我现在只能选择其中一个“Gewonnen”或“Verloren”或“Eingepasst”(请参见屏幕截图)。但是,点击“Eingepasst”后,我无法再点击“Gewonnen”或“Verloren”。选择AngularJS和CSS的按钮并不完全工作
下面是HTML代码:
<div class="padding">
<div class="button-bar">
<button ng-click="round.won=true" ng-class="{'active':round.won && !adjustedYesNo}" class="button button-outline">Gewonnen</button>
<button ng-click="round.won=false" ng-class="{'active': !round.won && !adjustedYesNo}" class="button button-outline">Verloren</button>
<button ng-click="adjusted()" ng-class="adjustedYesNo?'active':''" class="button button-outline">Eingepasst</button>
</div>
</div>
这里是CSS文件的相关部分:
.button {
border-radius: 10px;
&.button-light {
color: $ci-green;
}
&.button-outline {
@include regular;
color: $ci-white;
border-color: $ci-white;
&.activated {
background-color: rgba($ci-white, .1);
border-color: $ci-white;
}
&.active {
border-color: $ci-white;
background-color: $ci-white;
color: $ci-green;
}
}
最后的JavaScript代码:
$scope.adjusted = function (adjustedYesNo)
{
$scope.adjustedYesNo = adjustedYesNo;
console.log("adjusted before: ", $scope.adjustedYesNo);
$scope.adjustedYesNo = true;
console.log("adjusted afterwards: ", $scope.adjustedYesNo);
return $scope.adjustedYesNo;
}
那么这里需要做什么?
谢谢,但这并不完全工作。在你的代码中,“Eingepasst”背后的ng-click事件被触发,但其颜色在第二次,第三次等时不会变为白色。分别“Eingepasst”未设置为“活动”。它仅在第一次点击时才起作用... – Joey
我可以将课程设置为活动状态,并且可以在单击按钮时更改颜色。我没有使用离子或sass测试它。看到这个plunk:http://plnkr.co/edit/GMwHgd3JQDjuBzEJVS5M?p=preview – Saad
再次感谢您的额外英里。 – Joey