0
我的“任何”类型的其内的多个对象的数组,因为这样应用到一个对象的函数:角2 - 在一个数组
//List of posts (array)
this.posts = [
//First Post (object)
{
userFirst: 'Teyah',
userLast: 'Tharpe',
postText: 'Good morning, everyone! Have a good day. :)',
//First Post's comments (array)
comments: [
//First Comment (object)
{
cFirstName: 'Jalen',
cLastName: 'Tharpe',
theirComment: 'Thank you'
},
//Second Comment (object)
{
cFirstName: 'Gerald',
cLastName: 'Matthews',
theirComment: 'Thank you! You do the same.'
}
]
},
//Second Post (object)
{
userFirst: 'Jordan',
userLast: 'Gibson',
postText: 'What is the move for today?',
comments: [
{
cFirstName: 'Joshua',
cLastName: 'Stewart',
theirComment: 'Party at my house!!!'
}
]
}
];
正如你可以看到,我有一个数组的帖子,其中包含对象,并在帖子对象中,我有一个评论列表。我试图将comment()
函数应用于其中一个对象。说,posts[0]
。有人会告诉我,如果这在Angular 2的范围内?如果是这样,请帮助。
如需更多代码/信息,请让我知道。
谢谢。
你想做什么? –
你是什么意思“应用评论()函数”? –