gpt4 book ai didi

angularjs - 在
 标签内重复 ng 信息的最佳方法

转载 作者:行者123 更新时间:2023-12-01 05:16:00 26 4
gpt4 key购买 nike

我想使用 angular 的 ngRepeat 或类似工具在“pre”块内创建一些格式化文本。例如,这样的事情:

function MyController($scope)
{
$scope.data = [{test:'one', children:[...]},{test:'two', children:[...]}];
}

<pre>
{{ngRepeat item in data}}
{{item.test}}
{{ngRepeat child in item.children}}
{{child.title}}
{{/ngRepeat}}
{{/ngRepeat}}
</pre>

显然,我可以建立字符串,但我很好奇是否有办法在 Angular 模板中做到这一点。

最佳答案

这是不可能的,你必须有一个父元素才能重复 - 我最近尝试了同样的事情

我的解决方案是

<mytag ng-repeat="x in y">{{x}}</mytag>

关于angularjs - 在 <pre> 标签内重复 ng 信息的最佳方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20505700/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com