【发布时间】:2018-08-29 14:13:38
【问题描述】:
来自 json 数组,类似于:
[{title: 'title1',
details: [{text: 'text1'},
{code: 'code1'},
{text: 'text2'},
{code: 'code2'},
{array: array1}]
...
},
{{title: 'title2',
details: [{text: 'text1'},
{text: 'text2'},
{array: array1},
{code: 'code1'},
...
我想打印 3 种不同类型的数据:文本、数组和代码。 文本任何问题,数组与
<table>
和代码使用highlight module 和
<pre><code highlight [code]="..."></code></pre>
那么,我的第一个打印应该是:
text1
code1 in code style
text2
code2 in code style
array1 in array style
第二个:
text1
text2
array1 in array style
code1 in code style
我对使用 *ngfor 循环和 ngif 有一些想法,但是如何访问键文本、表格和代码来执行 ngif? 或者如果您看到更简单的解决方案?...
【问题讨论】:
-
到目前为止你尝试过什么?为什么不满意?
-
这是一个很好的 order-keys 问题,请再读一遍 ;)
-
类似这样的...stackblitz.com/edit/…
-
非常感谢 Ashish Ranjan :) 感谢理解我(至少不是 3 个人......)并感谢帮助我。明天我会尝试调整您的解决方案,但看起来不错。我注意到你使用钥匙的聪明技巧,太好了! :)