gpt4 book ai didi

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

转载 作者:太空狗 更新时间:2023-10-29 18:03:53 25 4
gpt4 key购买 nike

我正在学习 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;

阅读有关输入的更多信息here .

关于在组件中使用模型的 Angular 2 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40208015/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com