我想编写基于Angular对象的数据,如此格式
records: Array<any>;
ngOnInit(){
this.records= [
{ CategoryID: 1, CategoryName: "Beverages", Description: "Coffees, teas" }, ];
"Employee"={
//Here How can i write Employee Data
}
我需要this.records.Employee.Id
的数据。
答案 0 :(得分:0)
让Employee成为子对象。
this.records= [
record1: { CategoryID: 1,
CategoryName: "Beverages",
Description: "Coffees, teas",
Employee:
{
Id: 123,
name: "John Doe"
}
}
]
现在以这种方式访问id
this.records.['record1'].Employee.Id
或
this.records.[0].Employee.Id