angular js: angular.bind example

angular.bind api doc see: http://docs.angularjs.org/#!/api/angular.bind

 

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(1,1);//3

var fun=angular.bind(obj, function(i,j){alert(this.a+i+j)},2);
fun(3);//6

 

你可能感兴趣的:(Angular)