Hey! @ Beast, your NG API is out--angular.bootstrap

Source: Internet
Author: User

@ The beast's NG API Learning--Angular.bootstrap

Angular.bootstrap

Use this feature to manually start the angular app. Ngscenario-based end-to-end testing cannot be started manually using bootstrap and requires the use of Ngapp.

Angular detects if the app has been started and allows only the first start, followed by every boot that will cause the browser console to error.

This prevents the application from having some singular results that multiple angular instances try to run on the DOM.

Format: Angular.bootstrap (Element,[nodules]);

Element:dom element, angular application-initiated root node

Modules: arrays, dependent modules for angular applications

Using code:

<div id= "Ngapp" ng-controller= "Democtrl" >

{{Value}}

</div>

<script>

Angular.module ("Demo", []). Controller ("Democtrl", ["$scope", function ($scope) {

$scope. Value = "Hello World";

}]);

Angular.bootstrap (document.getElementById ("Ngapp"), ["Demo"]), "Hello World" displayed in//div

</script>

Official profile also translated, using the code is also affixed, the following write @ The Beast's own understanding of the Angular.bootstrap

The contact time of NG may not be long, the understanding is not deep enough, for angular.bootstrap feel also have nothing to say, Angular.bootstrap used to manually start angular application.

In general, we write NG programs that write Ngapp instructions on the page DOM element to start the angular program, but there may be special cases where we need to do something before we start or we need to start the application manually. At this time the angular.bootstrap is in handy.

Explain the following parameters:

The first parameter element, which refers to which DOM node the angular application needs to start at the root, the above code, the @ beast gives a div with ID Ngapp, and starts the application with him as the root;

The second parameter [modules] is the name of the module on which the application relies, and is an array of elements of type string, which tells angular which modules the program needs to depend on to function properly;

All right, so much for today. Continue tomorrow, last week translated 20 of several APIs are slowly written up, also need to save some time at night to continue to translate and learn the following API.

Hey! @ Beast, your NG API is out--angular.bootstrap

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.