I opened a ng-repeat block and I want to use "id" as counter for define toggle button counter in ng-click like this:
my code:
<div ng-repeat="line in linesList">
<a ng-click="'modal{{line.id}=!modal{{line.id}}'">{{line.id}}</>
</div>
my result is like this:
ng-click="'modal1=!modal1'"
but I need this:
ng-click="modal1=!modal1"
You can use an object 'modal', not multiple variables modal1, modal2, etc.
In your controller :
$scope.modal = {}
$scope.toggleModal = function(id) {
$scope.modal[id] = !$scope.modal[id]
}
And then:
<div ng-repeat="line in linesList">
<a ng-click="toggleModal(line.id)">{{line.id}}</>
</div>
See example here : http://codepen.io/thierry36t/pen/QGqPyj
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.