ANGULARJS Directive Custom Instructions

Source: Internet
Author: User

Function: Need to use directive to have the following scenario:

1. Make your HTML more semantic, without needing to drill down into the code and logic to know the approximate logic of the page.
2. Abstract a custom component and reuse it elsewhere.

3. Use common code, reduce re-use, reduce duplication of code,

Properties of the directive:

The scope of the study:

3 kinds of values for the scope property:

1.false (default) when using false to understand that there is no new scope within the directive, it shares the same scope with code other than the instruction, that is, the scope in the instruction is the same as the $scope in the controller,----------inheritance is not isolated.

2.true when using ture, it can be understood that all scopes within the directive inherit from the outside parent scope, but the change in the value inside the instruction does not affect the external value. -------------Inheritance Isolation

3. {}

To create a new "quarantine" scope, there are three types of binding strategies:
@: One-way binding, the external scope can affect the internal scope, but the reverse is not true, the value of the single-binding must be used {{}}

=: two-way binding, external scope and internal scope model can change each other, the value of double binding with "" can

&: Binds the return value of the function of the internal scope to any property of the external scope, generally using ""

See details: 52213103;

Restrict properties:

Desirable value: 1. E (Element) Label shape

2.A (Attrute) attribute shape

3.C (Class) type

4. M Comment Annotation Type

Template property:

The template is the instruction link DOM templates, which are generally HTML code.

Templaturl Properties:

Templateurl is an inline template that specifies a string, which is not used if you specify that the template is a URL. is typically specified as another page template.

Replace Property:

When true: indicates that the link template replaces the original element, that is, the content of the template replaces the original page.

When false: indicates that the link template does not replace the original element, that is, the contents of the template do not replace the original page.

Regular and transclude: boolean use

Link attribute: Pending study.

ANGULARJS Directive Custom Instructions

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.