简体   繁体   中英

Angular 2 error using model in component

I am learning Angular 2 and I am getting a strange error:

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.

Here is my "model":

recipe.ts

export class Recipe {
    constructor(public name, public description, public imagePath) {

    }
}

Here is my 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() {
  }

}

What could be the problem? Thanks.

Your model isn't the problem here, you are missing () on @Input decorator:

@Input() recipe: Recipe;

Read more about Input here .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM