【发布时间】:2019-04-25 21:30:56
【问题描述】:
控制台显示错误并显示配方未定义。
最后我添加了单独文件的类定义。
导入声明:
import { Recipe } from '../recipe.model';
新配方
export class RecipeListComponent implements OnInit {
recipes : Recipe[] = [
new Recipe('Test 1','Test Description','https://www.gimmesomeoven.com/wp-content/uploads/2014/03/Cajun-Jambalaya-Recipe-with-Andouille-Sausage-Shrimp-and-Chicken-3-1.jpg')
];
constructor(){}
ngOnInit() {
}
}
类定义:
export class Recipe {
public name : string;
public description : string;
public imagePath : string;
constructor(name :string, description : string, imagePath : string){
this.name=name;
this.description=description;
this.imagePath=imagePath;
}
}
【问题讨论】:
-
课程论坛是问这个问题的更好地方;)查看模块和应用程序文件,看看您是否在所有需要的地方都定义了食谱。
标签: javascript angular typescript