AngularJS provides instructions for binding application data to the attributes of an HTML DOM element.
ng-disabled directive
The ng-disabled directive binds the application data directly to the disabled property of the HTML.
<!DOCTYPE HTML><HTML> <Head> <MetaCharSet= "Utf-8"> <Scriptsrc= "Http://apps.bdimg.com/libs/angular.js/1.4.6/angular.min.js"></Script> </Head> <Body> <DivNg-app=""Ng-init= "Myswitch=true"> <P> <Buttonng-disabled= "Myswitch">Dot me!</Button> </P> <P> <inputtype= "checkbox"Ng-model= "Myswitch" />Button</P> <P>{{myswitch}}</P> </Div> </Body></HTML>
Example Explanation:
The ng-disabled directive binds the application data "myswitch" to the disabled property of the HTML. The Disabled property specifies that the input element should be disabled, and the disabled INPUT element is neither available nor clickable.
The ng-model directive binds "myswitch" to the contents of the HTML input checkbox element (value).
If myswitch is true, the button will not be available:
<p>
<button disabled> Point me! </button>
</P> if
myswitch is
false, the button is available: <p>
<button> Point me! </button>
</P> Ng-show directive
The ng-show directive hides or displays an HTML element.
<!DOCTYPE HTML><HTML> <Head> <MetaCharSet= "Utf-8"> <Scriptsrc= "Http://apps.bdimg.com/libs/angular.js/1.4.6/angular.min.js"></Script> </Head> <Body> <DivNg-app=""> <PNg-show= "true">I was visible.</P> <PNg-show= "false">I am not visible.</P> </Div> </Body></HTML>
The ng-show Directive Displays (hides) HTML elements based on value values.
You can use an expression to evaluate a Boolean value (True or FALSE):
<!DOCTYPE HTML><HTML> <Head> <MetaCharSet= "Utf-8"> <Scriptsrc= "Http://apps.bdimg.com/libs/angular.js/1.4.6/angular.min.js"></Script> </Head> <Body> <DivNg-app=""Ng-init= "Hour=13"> <PNg-show= "Hour >">I was visible.</P> </Div> </Body></HTML>
Ng-hide directive
The ng-hide directive is used to hide or display HTML elements.
<!DOCTYPE HTML><HTML> <Head> <MetaCharSet= "Utf-8"> <Scriptsrc= "Http://apps.bdimg.com/libs/angular.js/1.4.6/angular.min.js"></Script> </Head> <Body> <DivNg-app=""> <PNg-hide= "true">I am not visible.</P> <PNg-hide= "false">I was visible.</P> </Div> </Body></HTML>
AngularJS HTML DOM