self.getNoteClass = function(status) {
return {
done: status,
pending: !status
};
};
我在书中遇到这样一个用法,传入参数必须是true或false,然后传入true就是返回done,false就是返回pending。
我想问下这种用法是angularjs里的特殊用法吗?表示不理解,请大神解答,谢谢!
PS:下面这个我自己写的例子是我比较能理解的一个较简单清楚的使用方式。
self.getClassname = function(string) {
var obj = {
'1' : even,
'2' : odd
};
return obj[string];
};
I guess this is meant to be used in conjunction with the
ng-class
built-in directive, in which case, the classNamedone
will be applied to the element whenstatus
is true, and classNamepending
will be applied to the element otherwise.You may see the "Map Syntax Example" section in the document for
ng-class
for reference.