(AngularJS) Make a "ng-show" true specifically for one element in a ng-repeat -


i'am begining in angular, , i'am asking if possible make "ng-show" true 1 element in "ng-repeat", , make false others?

i explain myself code:

html file :

      <tbody ng-repeat="elem in list"  ng-init="visible = false">                     <tr ng-class="elemselected(elem)">                         <td colspan="3">                             <a href ng-click="clickelemscroll(elem)"   >                             <span class="glyphicon" ng-class="visible? 'glyphicon-chevron-down' : 'glyphicon-chevron-right'"></span>                             <strong>{{elem.name}} </strong>                             </a>                         </td>                     </tr>                     <tr ng-show="visible" >                       blabla                     </tr> </tbody> 

js file :

  $scope.clickelemscroll = function (elem) {                     if ($scope.elemselected === elem) {                         $scope.visible = true                     }                  }; 

as know, issue elem scrolled, how make element click visible ?

you can set new property onto element use in ngrepeat. also, not sure going on ng-class don't recommend using function in there. if trying set class when selected, try ng-class="{'selected': elem.selected}"

  <tbody ng-repeat="elem in list">         <tr ng-class="elemselected(elem)">              <td colspan="3">                   <a href ng-click="elem.selected = !elem.selected">                      <span class="glyphicon" ng-class="visible? 'glyphicon-chevron-down' : 'glyphicon-chevron-right'"></span>                         <strong>{{elem.name}} </strong>                   </a>              </td>         </tr>         <tr ng-show="elem.selected">              blabla         </tr> 


Comments

Popular posts from this blog

networking - Vagrant-provisioned VirtualBox VM is not reachable from Ubuntu host -

c# - ASP.NET Core - There is already an object named 'AspNetRoles' in the database -

ruby on rails - ArgumentError: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true -