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">

fiddle demo


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -