Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 971
Adrian Avatar asked Nov 21 '25 08:11

Adrian


1 Answers

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

@Input() recipe: Recipe;

Read more about Input here.

like image 142
Stefan Svrkota Avatar answered Nov 23 '25 02:11

Stefan Svrkota