加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

使用组件中的模型的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,我收到一个奇怪的错误:

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的更多信息.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读