- AngularJS - Internationalization
- AngularJS - Custom Directives
- AngularJS - Dependency Injection
- AngularJS - Services
- AngularJS - Scopes
- AngularJS - Views
- AngularJS - AJAX
- AngularJS - Includes
- AngularJS - Forms
- AngularJS - Modules
- AngularJS - HTML DOM
- AngularJS - Tables
- AngularJS - Filters
- AngularJS - Controllers
- AngularJS - Expressions
- AngularJS - Directives
- AngularJS - First Application
- AngularJS - MVC Architecture
- AngularJS - Environment Setup
- AngularJS - Overview
- AngularJS - Home
AngularJS Applications
- AngularJS - Lastfm Application
- AngularJS - Leaflet Application
- AngularJS - Timer Application
- AngularJS - Weather Application
- AngularJS - Share Application
- AngularJS - Maps Application
- AngularJS - Chart Application
- AngularJS - Translate Application
- AngularJS - Cart Application
- AngularJS - Drag Application
- AngularJS - Search Tab
- AngularJS - Order Form
- AngularJS - Switch Menu
- AngularJS - Nav Menu
- AngularJS - In-line Application
- AngularJS - Upload File
- AngularJS - Login Application
- AngularJS - Bootstrap Application
- AngularJS - Notepad Application
- AngularJS - ToDo Application
AngularJS Useful Resources
- AngularJS - Discussion
- AngularJS - Useful Resources
- AngularJS - Quick Guide
- AngularJS - Questions and Answers
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
AngularJS - HTML DOM
The following directives are used to bind apppcation data to the attributes of HTML DOM elements −
Sr.No. | Name & Description |
---|---|
1 | ng-disabled disables a given control. |
2 | ng-show shows a given control. |
3 | ng-hide hides a given control. |
4 | ng-cpck represents a AngularJS cpck event. |
ng-disabled Directive
Add ng-disabled attribute to an HTML button and pass it a model. Bind the model to a checkbox and see the variation.
<input type = "checkbox" ng-model = "enableDisableButton">Disable Button <button ng-disabled = "enableDisableButton">Cpck Me!</button>
ng-show Directive
Add ng-show attribute to an HTML button and pass it a model. Bind the model to a checkbox and see the variation.
<input type = "checkbox" ng-model = "showHide1">Show Button <button ng-show = "showHide1">Cpck Me!</button>
ng-hide Directive
Add ng-hide attribute to an HTML button and pass it a model. Bind the model to a checkbox and see the variation.
<input type = "checkbox" ng-model = "showHide2">Hide Button <button ng-hide = "showHide2">Cpck Me!</button>
ng-cpck Directive
Add ng-cpck attribute to an HTML button and update a model. Bind the model to HTML and see the variation.
<p>Total cpck: {{ cpckCounter }}</p> <button ng-cpck = "cpckCounter = cpckCounter + 1">Cpck Me!</button>
Example
The following example shows use of all the above mentioned directives.
testAngularJS.htm
<html> <head> <title>AngularJS HTML DOM</title> </head> <body> <h2>AngularJS Sample Apppcation</h2> <span ng-app = ""> <table border = "0"> <tr> <td><input type = "checkbox" ng-model = "enableDisableButton">Disable Button</td> <td><button ng-disabled = "enableDisableButton">Cpck Me!</button></td> </tr> <tr> <td><input type = "checkbox" ng-model = "showHide1">Show Button</td> <td><button ng-show = "showHide1">Cpck Me!</button></td> </tr> <tr> <td><input type = "checkbox" ng-model = "showHide2">Hide Button</td> <td><button ng-hide = "showHide2">Cpck Me!</button></td> </tr> <tr> <td><p>Total cpck: {{ cpckCounter }}</p></td> <td><button ng-cpck = "cpckCounter = cpckCounter + 1">Cpck Me!</button></td> </tr> </table> </span> <script src = "https://ajax.googleapis.com/ajax/pbs/angularjs/1.3.14/angular.min.js"> </script> </body> </html>
Output
Open the file testAngularJS.htm in a web browser and see the result.
Advertisements