search

Home  >  Q&A  >  body text

angular.js - How does angularjs elegantly implement an activation style that triggers one of multiple buttons?

As shown in the picture, there are three buttons. Click any one of them and the button will turn into a blue background, and the other two buttons will return to the default white color

<button type="button" class="btn" ng-click='toggle()' ng-class='active'>按钮1</button>
<button type="button" class="btn " ng-click='toggle()'>按钮2</button>
<button type="button" class="btn " ng-click='toggle()'>按钮3</button>

In controller:

$scope.toggle=function(){
  ··· 
}
世界只因有你世界只因有你2794 days ago587

reply all(1)I'll reply

  • 怪我咯

    怪我咯2017-05-15 17:04:24

    Little Elegance: demo

    reply
    0
  • Cancelreply