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.