AngularJS HTML DOM

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.