angularjs – 在标签内部重复信息的最佳方法
发布时间:2020-12-17 16:58:28 所属栏目:安全 来源:网络整理
导读:我想使用angular的ngRepeat或类似的方法在“pre”块中创建一些格式化的文本.例如,像这样: function MyController($scope){ $scope.data = [{test:'one',children:[...]},{test:'two',children:[...]}]; }pre {{ngRepeat item in data}} {{item.test}} {{ngR
我想使用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> (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |