This article mainly introduces AngularJS single-choice and multi-choice boxes for Bidirectional dynamic binding. If you need it, refer to the two-way Data Binding mentioned in AngularJS, you will surely think of the ng-model command.
I. ng-model
The ng-model command is used to bind the input, select, textarea, or custom form controls with attributes in their scopes. It binds the values of arithmetic expressions in the current scope to the given elements. If the property does not exist, it is implicitly created and added to the current scope.
Always use ng-model to bind attributes in a data model on the scope, instead of attributes on the scope, which can avoid overwriting attributes in the scope or the scope of future generations!
Ii. type = "radio"
You can use the value attribute to specify the corresponding value in the selected state, and use ng-model to map a single volume to the attribute in $ scope. This enables bidirectional dynamic binding when type = "radio.
MaleFemale
Iii. type = "checkbox"
Use the built-in commands ng-true-value and ng-false-value in AngularJS to specify the values of multiple selection boxes in the selected and unselected states, then, the ng-model corresponds to the attribute in $ scope, and the type = "checkbox" bidirectional dynamic binding is realized.
Table TennisFootballBasketball
Iv. Complete example
Radio & checkbox