【发布时间】:2018-07-07 02:16:13
【问题描述】:
我试图将对象推入我的数组,但它显示错误
意外的令牌。需要构造函数、方法、访问器或属性
在Model-form.component.ts 文件中,我创建了虚拟 json 数组进行测试。
json 数组:
test: any[] = [{
"cat_id": "1",
"cat_name": "One",
"cat_type": "One",
"displayOrder": 1,
"columns": [{
"category": "One",
"name": "one"
}]
},
{
"cat_id": "2",
"cat_name": "SECURITY",
"cat_type": "security",
"displayOrder": 2,
"columns": [{
"category": "Two",
"name": "two"
}]
},
{
"cat_id": "3",
"cat_name": "COLLOBORATION",
"cat_type": "colloboration",
"displayOrder": 3,
"columns": [{
"category": "Three",
"name": "three"
}]
},
{
"cat_id": "4",
"cat_name": "NEW ARCHITECTURE",
"cat_type": "newarch",
"displayOrder": 4,
"columns": [{
"category": "Four",
"name": "four"
}]
}
];
我已经尝试将对象推送到下面代码给出的测试数组中
this.test.push({
'cat_name': 'fdas',
'cat_type': 'fsda'
});
但它显示错误。 Code URL
【问题讨论】:
标签: javascript angular typescript