javascript 用于标记属性的 Angularjs ng-repeat 项

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18546994/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-27 12:21:23  来源:igfitidea点击:

Angularjs ng-repeat item for tag attributes

javascriptangularjs

提问by Vladimir Nani

My question is how can I use itemfrom ng-repeaton the same tag I am declaring ng-repeat

我的问题是如何使用item来自ng-repeat于我声明相同的标记ng-repeat

What I need (in some abstract template language):

我需要什么(在一些抽象模板语言中):

{% for item in items %}
     <li data-theme="{{ item.dataTheme }}">{{ item.name }}</li>
{% endfor %}

With angular I do not know how to access that item.dataTheme

使用 angular 我不知道如何访问它 item.dataTheme

<li data-theme="{{ item.dataTheme }}" ng-repeat="item in items">{{ item.name }}</li>

回答by Arun P Johny

You can use

您可以使用

<li data-theme="{{ item.dataTheme }}" ng-repeat="item in items">{{ item.name }}</li>

Demo: Fiddle

演示:小提琴