我在这里遇到错误,无法在服务中找到名称'id'
import { Injectable } from '@angular/core';
@Injectable()
export class AppService {
coins= [
{id=1,name='ajay'},
{id=2, name='venkatesh'}
];
constructor() { }
getMyItems(){
return this.coins;
}
}
答案 0 :(得分:1)
您使用的是无效的JSON,
coins= [
{id:1,name:'ajay'},
{id:2, name:'venkatesh'}
];
答案 1 :(得分:1)
coins= [
{'id':1,'name':'ajay'},
{'id':2, 'name':'venkatesh'}
]