How to highlight a selected row in ngRepeat?

前端 未结 3 1949
Happy的楠姐
Happy的楠姐 2020-12-02 13:56

I couldn\'t find something that will help me to solve this simple issue in Angular. All the answers are relevant for navigation bars when a comparison is being made against

3条回答
  •  抹茶落季
    2020-12-02 14:51

    Each row has an ID. All you have to do is to send this ID to the function setSelected(), store it (in $scope.idSelectedVote for instance), and then check for each row if the selected ID is the same as the current one. Here is a solution (see the documentation for ngClass, if needed):

    $scope.idSelectedVote = null;
    $scope.setSelected = function (idSelectedVote) {
       $scope.idSelectedVote = idSelectedVote;
    };
    
      ...

    Plunker

提交回复
热议问题