@ 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