How to add custom attribute to HTML tag using AngularJS

I need to dynamically mark some <button> as having the value as correct=true or correct=false . I see how to use. Ideally, this attribute will be invisible to the user who clicks "View Source". I can live with the answer visible through the JavaScript debugger.

Now I store it in a separate data structure and view it through the id, which is dynamically constructed by AngularJS:

 <div style="padding-top: 5px" class="col-md-offset-3" ng-repeat="answer in answers"> <button id="answerChoice_{{$index}}" style="font-size: 18px;" class="btn btn-default" ng-click="selectButton($event)" > {{answer}} </button> </div> 
0
source share
1 answer

ng comes with a jquery light version, so you can script something like

 $('button').attr("correct",true); 
+2
source

All Articles