AngularJS无法在ID中包含标记?(AngularJS not able to include markup in IDs?)

系统教程 行业动态 更新时间:2024-06-14 17:01:34
AngularJS无法在ID中包含标记?(AngularJS not able to include markup in IDs?)

我有一个3项的数组,并希望它们是“ng-repeated”

<li ng-repeat="item in obj.items id="testobj{{testobj.number}}"> </li>

当我查看页面时,似乎“li”的id对于所有3个项目而言只是“testobj”而不是像我期望的那样testobj1 testobj2 testobj3。 有什么问题?

I have an array of 3 items and want them to be "ng-repeated"

<li ng-repeat="item in obj.items id="testobj{{testobj.number}}"> </li>

When I look at the page, it appears that the id of the "li" is just "testobj" for all 3 items and not testobj1 testobj2 testobj3 like I was expecting. What is the issue?

最满意答案

您的ng-repeat属性缺少最终的“。

{{}}绑定可能会返回没有数据,因此被视为空字符串。 我看到在绑定之外的任何地方都没有引用testobj (范围变量)。 这是定义的,还是你的id读取id="testobj{{item.number}}"或类似的东西?

Your ng-repeat attribute is missing a final ".

The {{ }} binding is probably coming back with no data and so being treated as if it was an empty string. I see no reference to testobj (the scope variable) anywhere outside of your binding. Is this defined, or should your id read id="testobj{{item.number}}" or something similar?

更多推荐

本文发布于:2023-04-20 18:35:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/dzcp/b8f93e21120a1f7f753639b096313b24.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:标记   ID   AngularJS   IDs   markup

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!