angularjs - Generate a dynamic HTML id using Angular JS -
angularjs - Generate a dynamic HTML id using Angular JS -
i have simple table looks follows:
<table id="responsegrid"> <tbody> <tr id="response" data-ng-repeat="response in data.responses"> <td id="resp key">{{response.key}}</td> <td id="resp value">{{response.value}}</td> </tr> </tbody> </table>
however, if more 1 row created, each table column have same id. want each table column have unique id based on row. instance, want first row have columns ids "resp key 1" , "resp value 1", next row have columns ids "resp key 2" , "resp value 2", , on.
is there way in angular js? tried looking sort of way of getting index of response on, doesn't seem work. also, can't figure out way concatenate id (although may more of html issue). help appreciated.
you can somthing $index
index of array
<tr id="response" data-ng-repeat="response in data.responses"> <td id="{{'resp key '+($index+1)}}">{{response.key}}</td> // result in `resp key 1`,`resp key 2` .. <td id="{{'resp value '($index+1)}}">{{response.value}}</td> </tr>
angularjs angularjs-ng-repeat
Comments
Post a Comment