angular.js - 请问关于AngularJS里数组对象的使用例子问题
PHP中文网
PHP中文网 2017-05-15 16:50:09
[AngularJS讨论组]
 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讲师

全部回复(1)
天蓬老师

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.

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习
PHP中文网抖音号
发现有趣的

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号