[英]Behavior with ng-show and ng-hide in angular
This is my code: html: 这是我的代码:html:
<div ng-controller="ButtonController">
<button class=" circle-white btn btn-collapse-custom" ng-click="collapse(1); toggleBtn()">
<i ng-show="imgbtn" class="fa fa-chevron-down"></i>
<i ng-hide="imgbtn" class="fa fa-times"></i>
</button>
</div>
js: js:
'use strict'
module.exports = function($scope , $rootScope ){
$scope.imgbtn = true;
$scope.toggleBtn = function() {
$scope.imgbtn = $scope.imgbtn === false ? true: false;
};
};
this work's fine. 这项工作很好。
the problem is when another button is clicked ,the previous click stay active so the cross don't change. 问题是单击另一个按钮时,前一个单击保持活动状态,因此十字不会改变。
first button , when clicked 单击第一个按钮
Now another button is clicked , and previous is active yet 现在,单击另一个按钮,并且先前的按钮仍处于活动状态
Idk how to change the 'active' , any other solution ? IDK如何更改“主动”,还有其他解决方案?
Just guessing what you want to achieve, but you should try this: 只是猜测要实现的目标,但是您应该尝试以下操作:
<div ng-controller="ButtonController">
<button class=" circle-white btn btn-collapse-custom" ng-click="collapse(1); imbtn = !imbtn">
<i ng-class="{'fa fa-chevron-down': imbtn, 'fa fa-times': !imbtn}">
</i>
</button>
</div>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.