Angular.bind (Obj,fun,args)
Obj: Object fun: Function arg: function to pass parameters (can be omitted).
Explanation: Dynamically binding a function to an object
Function: Implement call Data modularization.
Demo:var Func = function (a) {
This.a=a;
}
var obj=New Func (1);
var fun=angular.bind (obj, function (i,j) {alert (this.a+i+j)},4,2);
Fun (); //7 var fun=angular.bind (obj, function (i,j) {alert (this.a+i+j)});
Fun (a); //3 var fun=angular.bind (obj, function (i,j) {alert (this.a+i+j)},2);
Fun (3); //6
Angular.bootstrap (element,["module"])
element: DOM element, document.getElementById ("") module: array, angular application dependent module
Explanation: The general angular is automatically loaded module, you can manually load the angular module by this method.
Demo
<html>
<head>
<script src="angular.js"></script>
<script>
//Create moudle1
var rootMoudle = angular.module(‘moudle1‘, []);
rootMoudle.controller("controller1",function($scope){$scope.name="aty"});
//Create moudle2
var m2 = angular.module(‘moudle2‘, []);
m2.controller("controller2",function($scope){$scope.name="aty"});
//After the page is loaded, load the module again
angular.element(document).ready(function() {
angular.bootstrap(document.getElementById("div1"),["moudle1"]);
angular.bootstrap(document.getElementById("div2"),["moudle2"]);
};
</script>
<head>
<body>
<div id="div1" ng-controller="controller1">div1:{{name}}</div>
<div id="div2" ng-controller="controller2">div2:{{name}}</div>
</body>
</html>
My first Blog essay: An understanding of the Angularjs API. Angular.bind () Angular.boostrap ()