[英]how can i selected a button to select a size for a shopping cart app using angularjs
this is my code in controller这是我在控制器中的代码
$scope.status = false;
$scope.clickOn = function () {
if ($scope.status == false) {
this.status = true;
} else {
this.status=false;
}
};
here is my html field这是我的 html 字段
<div class="sizes">
<button ng-repeat="size in $ctrl.cart.sizes" class="button-size"
ng-class="{true:'active',false:'deactive'}[status]" ng-click="clickOn()">
<span>{{size}} UK</span>
</button>
</div>
when I click on the button the class active have been used but when I click again the class deactive never work there are any solution for this ??当我单击按钮时,活动类已被使用,但是当我再次单击时,活动类从不工作,有任何解决方案吗? thanks you guys so much
非常感谢你们
You may want to add "track by $index" and activate/deactivate the button based on the $index.您可能需要添加“track by $index”并根据 $index 激活/停用按钮。 Hope this helps.
希望这可以帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.