Angular study notes (ix)-CSS class and Style 1

Source: Internet
Author: User

This article focuses on using data binding to add a specific class name to an element to apply a specific style

From one of the most basic examples:

<!DOCTYPE HTML><HTMLNg-app><Head>  <title>6.1CSS Classes and Styles</title>  <MetaCharSet= "Utf-8">  <Scriptsrc=".. /angular.js "></Script>  <Scriptsrc= "Script.js"></Script>  <styletype= "Text/css">. Submit-false{background:#efefef;Color:#ccc}Button{Border:1px solid #ccc;Outline:0}  </style></Head><Body>  <DivNg-controller= "Buttondisable">    <Buttonclass= "submit-{{Disable}}"Ng-click= "deactive ()">Submit</Button>  </Div></Body></HTML>

A Submit button, which will be disabled after clicking, appears dimmed:

Add the class name submit-{{disable}} to the button so that the change of the disable will cause a change in the button class name,

When the value of the disable variable is false, it will be stitched into the Submit-false class name, using the corresponding style

function buttondisable ($scope) {    $scope.   true ;     function () {        false    }}

Original state:

After one click:

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.