我正在学习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.
Supplied parameters do not match any signature of call target.
这是我的“模特”:
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的更多信息.