如何将逗号分隔的JSON值显示为列表?
问题描述:
说我有一个像这样的数组:
Say I have an array like this:
var ARTISTS: Artist[] = [
{
"name": "Barot Bellingham",
"shortname": "Barot_Bellingham",
"reknown": "Royal Academy of Painting and Sculpture",
"bio": "Some bio here...",
"friends": "James, Harry, Bob"
}
是否可以将键朋友"的值显示为无序列表,其中每个朋友都是其自己的列表项,例如:
Is it possible to display values for the key "friends" as an unordered list where each friend would be it’s own list item, e.g.:
<ul>
<li>James</li>
<li>Harry</li>
<li>Bob</li>
</ul>
我确实意识到,最好将朋友"存储为嵌套数组以显示为列表,但我正在将其视为另一个问题的潜在解决方法.
I do realize the "friends" would be better stored as a nested array in order to display as a list, but I'm looking into this as a potential workaround for another issue.
谢谢!
P.S.我正在使用Angular 2.
P.S. I'm using Angular 2.