找不到模块“ id”

时间:2018-09-17 14:16:53

标签: angular angular5 angular-services

我在这里遇到错误,无法在服务中找到名称'id'

import { Injectable } from '@angular/core';
@Injectable()
export class AppService {
 coins= [
   {id=1,name='ajay'},
   {id=2, name='venkatesh'}
];
  constructor() { }
  getMyItems(){
  return this.coins;
  }
}

2 个答案:

答案 0 :(得分:1)

您使用的是无效的JSON,

 coins= [
   {id:1,name:'ajay'},
   {id:2, name:'venkatesh'}
];

答案 1 :(得分:1)

 coins= [
   {'id':1,'name':'ajay'},
   {'id':2, 'name':'venkatesh'} 

]