AngularJS basic styles-AngularJS-js tutorial

Source: Internet
Author: User
This article mainly introduces some basic AngularJS styles. AngularJS is a highly popular JavaScript framework. For more information, see Show and hide

Everything in Angular is based on model changes, which are then reflected on the interface through identifiers.
Ng-show and ng-hide can do the same thing. Display and hide are based on the expressions you pass to them, that is, when the expression is true, ng-show is displayed, and vice versa. If the expression is true, ng-hide is hidden and displayed on the contrary. These identifiers work by setting the element style display: block display and display: none hide.
CSS class and Style

Data Binding can be performed through {} parsing to dynamically set classes and styles.
Ng-class and ng-style

In large projects, the above method makes it difficult to manage, so that you have to read templates and JavaScript at the same time to create css correctly.
Angular provides ng-class and ng-style identifiers. Each of them requires an expression. The result of expression execution may be one of the following:

  • A string that represents the names of classes separated by spaces.
  • An array of class names
  • Ing between a class name and a Boolean Value

Selected row

In the template, we set the ng-class value to {selected: $ index = selectedRow}. When the model calls selectedRow, it will match the $ index of ng-repeat, the selected style is displayed. Similarly, we set ng-click to notify the Controller user which line has been clicked.
Src and href suggestions

Ng-src and ng-href are recommended.

segmentfault

All source code

  
   Angular demo  

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.