javascript - show/hide elements (div) in a dynamically generated table angularjs -
i have created working table in angularjs, this:
<div class="table-responsive"> <table class="table table-striped table-hover"> <thead> <tr> <th class="col-xs-12" ng-click="sort('firstname')"> <span class="glyphicon sort-icon" ng-show="sortkey=='firstname'" ng-class="{'glyphicon-chevron-up':reverse,'glyphicon-chevron-down':!reverse}"></span> </th> </tr> </thead> <tbody> <tr ng-click="showmodal($event, user.emailaddress)" dir-paginate="user in users|orderby:sortkey:reverse|filter:search|itemsperpage:5"> <td> <div style="padding-top:1em">{{product name}} <div> <div style="padding-top:1em">complete target in:<span> 23 days</span> </div> <div>completion status: done</div> </div> <div style="padding-top:1em">show more details</div> <div ng-show='false'>some product description here</div> </td> </tr> </tbody> </table> </div> </div>
for each element want able expand product details dynamically - when click on div show more details, div containing product details shown - when user presses button again, div contains details hidden.
<div style="padding-top:1em">show more details</div> <div ng-show='false'>some product description here</div>
how can in angularjs. thanks
if you're using ng-repeat
build table, can this:
<div ng-click="show{$index}=!show{$index}">show more details</div> <div ng-show="show{$index}">some product description here</div>
if not, you'll want directive:
<div class="details-toggler">show more details</div> <div class="details">some product description here</div> <script> app.directive('detailstoggler', function () { return { restrict: 'c', compile: function (element, attr) { return function (scope, element) { element.on('click', function (event) { $(element).next('.details').slidetoggle(); }); } } } }) </script>
Comments
Post a Comment