开发者社区 问答 正文

AngularJs的表达式问题?报错

<li ng-repeat="constructor in roommates | orderBy:'id':true" ng-class="{first:$first}">
        <a ng-click="speak(constructor.id)">id:{{constructor.id}},姓名:{{constructor.name}}</a>
    </li>

今天刚发现的问题,上面的代码在click的时候浏览器的console会报错,angualrjs给出的解释是:

Referencing Object in Angular expressions is disallowed!

但我把

ng-repeat="constructor in roommates

改成

ng-repeat="c in roommates

就可以了,求大神解释了为什么?


展开
收起
爱吃鱼的程序员 2020-06-09 11:47:55 693 分享 版权
1 条回答
写回答
取消 提交回答
  • https://developer.aliyun.com/profile/5yerqm5bn5yqg?spm=a2c6h.12873639.0.0.6eae304abcjaIB

    constructor是关键字啊

    嗯,已经知道了,尴尬了!!
    2020-06-09 11:48:11
    赞同 展开评论
问答地址: