angular.js - 请问关于AngularJS里数组对象的使用例子问题
PHP中文网
PHP中文网 2017-05-15 16:50:09
0
1
623
 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];
  };
PHP中文网
PHP中文网

认证高级PHP讲师

reply all(1)
Peter_Zhu

I guess this is meant to be used in conjunction with the ng-class built-in directive, in which case, the className done will be applied to the element when status is true, and className pending will be applied to the element otherwise.

You may see the "Map Syntax Example" section in the document for ng-class for reference.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template