@H_5020@angular.bind
@H502_0@解释:返回一个调用self的函数fn(self代表fn里的this).可以给fn提供参数args(*).这个功能也被称为局部操作,以区别功能。
@H_5020@格式:angular.bind(self,fn,args);
@H502_0@self:object 对象; fn的上下文对象,在fn中可以用this调用
@H_502_0@fn:function; 绑定的方法
@H_502_0@args:传入fn的参数
<div class="jb51code">
<pre class="brush:js;">
var obj = { name: "Any" };
var fn = function (Adj) {
console.log(this.name + "is a boy!!! And he is " + Adj + " !!!");
};
var f = angular.bind(obj,"handsome");
f();//Any is a boy!!! And he is handsome!!!
var t = angular.bind(obj,fn);
t("ugly");// Any is a boy!!! And he is ugly!!!