无法绑定到“选项”,因为它不是“p-dropdown”的已知属性

Bil*_*lly 3 primeng angular

尝试向 userform.component.ts 添加 primeNG 下拉列表时出现此错误,我已经引用了此但无济于事,因为我已经实施了此修复程序:primeng 下拉组件错误('p-dropdown' 不是已知元素)

Uncaught Error: Template parse errors:
Can't bind to 'options' since it isn't a known property of 'p-dropdown'.
1. If 'p-dropdown' is an Angular component and it has 'options' input, then verify that it is part of this module.
2. If 'p-dropdown' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.
3. To allow any property add 'NO_ERRORS_SCHEMA' to the '@NgModule.schemas' of this component. ("<p-dropdown [ERROR ->][options] = "technologies" [autoWidth] = "false" id = "technologies"></p-dropdown>
Run Code Online (Sandbox Code Playgroud)

GIT 回购:https : //github.com/BillyCharter87/Tech-O-Dex

谢谢!

小智 6

通常,当您错过某些导入时会发生此错误。如果缺少,请添加这些行:

import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { DropdownModule } from 'primeng/primeng';
Run Code Online (Sandbox Code Playgroud)

并将它们添加到导入中。


小智 3

您可能正在p-dropdown另一个组件中使用,并且在您尚未导入的另一个组件的模块中使用DropdownModule。我犯了同样的错误,并通过放入以及特定组件的模块中得到DropdownModule解决AppModule