使用组件中的模型的Angular 2错误
发布时间:2020-12-17 17:06:11 所属栏目:安全 来源:网络整理
导读:我正在学习Angular 2,我收到一个奇怪的错误: ERROR in [default] /home/szabo/PhpstormProjects/recipe-book/src/app/recipes/recipe-list/recipe-item.component.ts:11:2 Unable to resolve signature of property decorator when called as an expression
我正在学习Angular 2,我收到一个奇怪的错误:
这是我的“模特”: recipe.ts export class Recipe { constructor(public name,public description,public imagePath) { } } 这是我的RecipeItemComponent: import {Component,OnInit,Input} from '@angular/core'; import { Recipe } from '../recipe'; @Component({ selector: 'app-recipe-item',templateUrl: './recipe-item.component.html',styleUrls: ['./recipe-item.component.css'] }) export class RecipeItemComponent implements OnInit { @Input recipe: Recipe; //line 11 recipeId: number; constructor() { } ngOnInit() { } } 可能是什么问题呢? 解决方法
你的模型不是问题,你在@Input装饰器上缺少():
@Input() recipe: Recipe; 阅读有关Input here的更多信息. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |