使用组件中的模型的Angular 2错误

前端之家收集整理的这篇文章主要介绍了使用组件中的模型的Angular 2错误前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在学习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的更多信息.

猜你在找的Angularjs相关文章