Angularjs Elegant Custom Instructions _angularjs

Source: Internet
Author: User
Tags button type eval pears

Learning points
• Why use instructions
• Create custom directives
• Work with Jqlite

Why use a custom directive
Ng has a number of custom directives built into it, but they sometimes don't meet your requirements, which is what we need to create custom attributes.

Ii. Custom Directives
Next, we do a small case, when the mouse clicks the increase, the list item automatically increments, of course, the list is automatically added through the instructions, it is an empty div

<! Doctype> <!--use module-->  

Analytical:
Step One: Create a controller, add a data model products and incremental price incrementprices () method
Step two: Customize the Unorderlist label, which is used to show the value of the scope data model in a unordered table
Part III: And when you click the Fare increase button, the unordered table values are incremented sequentially

Third, the use of jqlite work
Ng has a built-in jqlite, it's a scaled-down version of jquery.

<! Doctype> <!--use module-->  

Analytical:
The first step: Customizing the controller, defining the data model names
Step Two: Custom directives, which function to find all the li under the elements of the instruction, and to give different colors to the font with a different value.
Step three: Call in the view and use the directive

The above is the entire content of this article, I hope to help you learn, but also hope that we support the cloud habitat community.

Related Article

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.