By binding to the initialization of angular, JS code will be hacked into the HTML, but for the novice use, still enough!
{{Hello}} </div> < Script type= "Text/javascript" > var mymodule = Angular.module ("myApp", []); Mymodule.controller ("Myctrl",function($scope) { = "hello,angular!" ; }); </script></body>
Manual initializationManual binding of the Api--bootstrap is also available in angular, which is used in the following ways:
Angular.bootstrap (element, [modules], [config]);
The first parameter, element, is the DOM element that binds Ng-app;
Modules: The module name of the binding
Config: Additional configuration
Simply look at the code:
{{Hello}}</div> <script type= "Text/javascript" >varApp = Angular.module ("Bootstraptest",[]); App.controller ("Myctrl",function($scope) {$scope. Hello= "Hello,angular from bootstrap"; }); //Angular.bootstrap (document.getElementById ("Body"), [' bootstraptest ']);Angular.bootstrap (document,[' bootstraptest ']); </script></body>It is worth noting that:
- Angular.bootstrap only binds objects that are loaded for the first time.
- Subsequent repeated bindings or bindings to other objects will output error prompts at the console.
AngularJS API's Bootstrap launch