HTML DOM element in AngularJS
The following AngularJS directives can be used to bind application data to attributes in the HTML DOM element.
- ng-disabled: Disabling a control (control) provided
- ng-show: Displays a control provided
- ng-hide: Hide a control provided
- ng-click: Performing a click event in AngularJS
Ng-disabled Directive in AngularJS
Add ng-disable attribute to an HTML button and attach this data to the model. Mount the model to a checkbox to observe the change.
type = "checkbox" ng-model = "enableDisableButton" > Disable button
Ng-show Directive in AngularJS
Add the ng-show attribute to the HTML button and attach it to the model. Mount the model to a checkbox to observe the change.
type = "checkbox" ng-model = "showHide1" > Show button
Ng-hide directive in AngularJS
Add ng-hide attribute to the HTML button and attach it to the model. Mount the model to a checkbox to observe the change.
type = "checkbox" ng-model = "showHide2" > Hide the button
Ng-click directives in AngularJS
Add the ng-click attribute to the HTML Button and attach it to the model. Mount the model to hmtl to observe the change.
Total clicks: {{clickCounter}}
For example
Here is an example for the description mentioned above.
phantuHTMLDOM.html
HTML DOM trong AngularJS
For example
AngularJS QTMng-app = "" >border = "0" > type = "checkbox" ng-model = "enableDisableButton" > Vô hiệu hóa nút
Tổng số lần nhấp: {{ clickCounter }}ng-click = "clickCounter = clickCounter + 1" > Nhấp vào đây!
Result:
Open the phantuHTMLDOM.html page on the web browser and see the results. If you click on the buttons one at a time, the result will be:
HTML DOM element in AngularJS Picture 1
According to Tutorialspoint
Previous article: Controller component in AngularJS
Next lesson: The Module in AngularJS