加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

angularjs – 如何在ion2/angular2中设置动态id(* ngFor)?

发布时间:2020-12-17 08:19:47 所属栏目:安全 来源:网络整理
导读:如何设置角度2中的动态ID? 我努力了 div class = "CirclePoint" *ngFor="#c of circles" id = "{{ 'Location' + c.id }}"/divthis.circles = [ { x: 50,y: 50,id : "oyut1" },{ x: 100,y: 100,id : "oyut3" },{ x: 150,y: 150,id : "oyut2" } ]; 但它不行。
如何设置角度2中的动态ID?

我努力了

<div class = "CirclePoint" *ngFor="#c of circles" 
id = "{{ 'Location' + c.id }}">
</div>

this.circles = [
        { x: 50,y: 50,id : "oyut1" },{ x: 100,y: 100,id : "oyut3"  },{ x: 150,y: 150,id : "oyut2"  }
    ];

但它不行。

<div class = "CirclePoint" *ngFor="let c of circles" 
    [attr.id]="'Location' + c.id">
</div>

<div class = "CirclePoint" *ngFor="let c of circles" 
    attr.id="Location{{c.id}}">
</div>

对于id属性,这可能也是有效的(还没有尝试过)

<div class = "CirclePoint" *ngFor="let c of circles" 
[id]="'Location' + c.id">
</div>

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读