javascript - Highlight selected row in ng-repeat with logic only in HTML -


this follow question of how highlight selected row in ngrepeat?

here row being highlighted using function defined in controller.i wanted make other way round,where want use code in html. below plunker have tried . plunker pls share thoughts on issue:

<tr ng-repeat="item in items"           ng-init="selectedrow = null"           ng-class="{'selected':selectedrow == $index}"            ng-click="selectedrow=$index" ></tr> 

have @ demo

<tr ng-repeat="item in items"           ng-init="selectedrow = null"           ng-class="{'selected':$parent.selectedrow == $index}"            ng-click="$parent.selectedrow=$index" >           <td>{{item.name}}</td>           <td>{{item.value}}</td>            <td><button class="btn btn-primary" ng-click="edit(item)">click</button></td>  </tr> 

function listctrl($scope, $dialog) {    $scope.items = [     {name: 'foo', value: 'foo value',car:'chevy',model:'vette',year:'2013'},     {name: 'bar', value: 'bar value'},     {name: 'baz', value: 'baz value'}   ];   $scope.selected = -1;   } 

Comments

Popular posts from this blog

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

android - How to create dynamically Fragment pager adapter -

1111. appearing after print sequence - php -