javascript - Cant set AngularJS variable in ng-reapeat -
i want implement list should visible after click. when try set value on ng-click
, value scope in on clicked element.
<ul data-ng-init="showiatalist = false"> {{showiatalist}} <-- false :( should true after click on link list <li data-ng-repeat="value in data.departureiatalist"> <a href="javascript:" data-ng-if="$index < 3 || showiatalist"> {{value}} </a> {{showiatalist}} <a href="javascript:" data-ng-if="!showiatalist && $index == 3" data-ng-click="showiatalist = true"> {{showiatalist}} <-- after click true, true should , on top showiatalist variable </a> </li> </ul>
fyi, every ng-repeat
item has own scope. reason why data-ng-click="showiatalist = true"
works specific scope , not main $scope
.
you can write example:
$scope.data.showiatalist = false;
and work
or in case: <ul data-ng-init="data.showiatalist = false">
Comments
Post a Comment