(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
Post a Comment