小编shu*_*ora的帖子

错误 NG2003:没有适合类的参数“id”的注入令牌

这是我的 service.ts 文件

import { Inject, Injectable } from '@angular/core';
import { inject } from '@angular/core/testing';

@Injectable({
  providedIn: 'root'
})


export class Product{
  constructor(
     public id: number,
     public title: string,
     public price: number,
     public rating: number,
     public description: string,
     public categories: string[]){}
}


export class ProductService {

  constructor() { }
  getProducts(): Product[] {
    return products.map(p =>new Product(p.id, p.title, p.price, p.rating, p.description, p.categories));
  }
}


const products =[
  {
    'id': 0,
    'title': 'First product',
    'price': 24.99,
    'rating': 4.3,
    'description': 'This is …
Run Code Online (Sandbox Code Playgroud)

angular angular6

2
推荐指数
1
解决办法
1万
查看次数

标签 统计

angular ×1

angular6 ×1