"Front-end" cattle practice problem accumulation--angularjs

Source: Internet
Author: User

Angularjs Aspects:

Whenever an instruction is created, there is an option to inherit its own parent scope (typically the scope or root scope ($rootScope) provided by the external controller), or to create a new scope of its own, of course angularjs for our instructions. The scope parameters provide three choices, namely: false , true , {} ; by default false .

When the scope property is set to true , this indicates that the instruction we created is to create a new scope that inherits from our parent scope.

When we scope set it to false , the instruction we create and the parent scope (which is actually the same scope) share the same model model, so the model data is modified in the directive, and it is reflected in the model of the parent scope.

scope:{} This property creates a separate scope and does not inherit the parent scope.

Note: In child scope, use $parent.parentscopeproperty. This prevents the child scope from creating its own properties and can modify the properties of the parent scope directly.

Compile three stages:
1. Standard Browser API conversions
Convert HTML to DOM, so custom HTML tags must conform to HTML format
2. Angular compile (bind DOM)
Search for matching directive, sort by priority, and execute the Compile method on directive
3. Angular Link (data binding)
Execute the link method on directive for scope binding and event binding

Angular JS the best way to use communication between control

Send message: $scope. $emit (name, data) or $scope. $broadcast (name, data);

Receive message: $scope. $on (Name,function (event,data) {});

Difference: $emit Broadcast to the parent controller $broadcast broadcast to the child controller

Broadcast is an event that is broadcast from the sender to his child scope.

$emit broadcast to the parent controller, the parent controller is able to receive the message

$on have two parameter function (EVENT,MSG) The first parameter is the event object, and the second parameter is the receipt of the message information

The then () method returns a promise. It has two parameters, the callback function for promise in the case of success and failure, respectively. P.then (function (value) {   //satisfy  }, function (reason) {  //deny});

Promise mode is in one of the following three states at any time: incomplete (unfulfilled), completed (resolved), and rejected (rejected).

"Front-end" cattle practice problem accumulation--angularjs

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.