My first Blog essay: An understanding of the Angularjs API. Angular.bind () Angular.boostrap ()

Source: Internet
Author: User



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 ()


Related Article

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.