我知道构造函数或类存在一些问题,但我不确定是什么问题。
我的食谱模型类如下所示:
export class Recipe{
public name : string;
public description :string;
public imagePath : string;
contructor(name : string , desc : string , imagePath :string){
this.name = name;
this.description = desc;
this.imagePath = imagePath;
}
}
这就是我的 recipe-list-component.ts ,
import { Component, OnInit } from '@angular/core';
import { Recipe } from '../recipe.model';
@Component({
selector: 'app-recipe-list',
templateUrl: './recipe-list.component.html',
styleUrls: ['./recipe-list.component.css']
})
export class RecipeListComponent implements OnInit {
recipes : Recipe[] = [
new Recipe('A Test Recipe' , 'This is test' , 'abc.jsp')];
constructor() { }
ngOnInit(): void {
}
}
谁能建议我如何解决这个问题。我正在使用 Angular CLI:10.0.5,节点:12.18.2。