AngularJS DOM
- The AngularJS provides directives for binding application data to the HTML DOM element’s attribute.
- These are the HTML DOM attributes used in AngularJS.
- Show as ng-show directive.
- Hide as ng-hide directive.
- Disabled as ng-disabled directive.
Syntax for HTML DOM in AngularJS:
Sample code for HTML DOM in AngularJS:
Data:
- Set of data has been used in our AngularJS Application.
HTML:
- Viewable HTML contents in AngularJS Application.
Logic:
- Controller logic for the AngularJS application.
Code Explanation for HTML DOM in AngularJS:
- The ng-hide directive is used to hide or show the textbox by changing the Boolean value myhide.
- The ng-show directive is used to hide or show the textbox by changing the Boolean value myshow.
- The ng-disabled directive is used to disable or enable the textbox by changing the Boolean value mydisabled.
- The “Show” button used to call the “showFun()” function.
- The “Hide” button used to call the “hideFun()” function.
- The “Disable” button used to call the “disFun()” function.
- The “DOMCtrl” used to create the controller for the Application with $scope object argument.
- The showFun is a function used to set myshow as true, myhide and mydisabled as false variable.
- The hideFun is a function used to set myhide as true, myshow and mydisabled as false variable.
- The disFun is a function used to set mydisabled and myshow as true and myhide as false variable.
Sample Output for $interval Service in AngularJS:
- The Values are empty on the page load.
- When user click the Show button then the textbox will be visible.
- When user Click the Hide button then the textbox will be disappear.
- When user click the Disable button then the textbox will be disabled so that user cannot edit the text.