我有一个角度组件,通常我会将此信息存储在数据库中,然后从那里检索它并构建此列表。但是,我这样做是Ionic框架学习过程的一部分,所以我在组件本身创建它。
我创建了以下静态列表:
export class Foo{
constructor(){
this.list= [
{
Id: 0, Line: "zero"
},
{
Id: 1, Line: "one"
},
{
Id: 2, Line: "two"
},
{
Id: 3, Line: "three"
},
{
Id: 4, Line: "four"
},
{
Id: 5, Line: "five"
},
{
Id: 6, Line: "six"
},
{
Id: 7, Line: "seven"
},
{
Id: 8, Line: "eight"
},
{
Id: 9, Line: "nine
},
{
Id: 10, Line: "ten"
},
{
Id: 11, Line: "eleven"
},
{
Id: 12, Line: "twelve"
},
{
Id: 13, Line: "thirteen"
},
{
Id: 14, Line: "fourtheen"
},
{
Id: 15, Line: "fiftheen"
},
{
Id: 16, Line: "sixteen"
},
{
Id: 17, Line: "seventeen"
},
{
Id: 18, Line: "eighteen"
},
{
Id: 19, Line: "nineteen"
},
{
Id: 20, Line: "twenty"
}
]
}
}
现在这个列表可以有n个对象,所以这些行会随着数量的增长而增长 - 我怎么能把它抽象出来呢?