无法绑定到 'options',因为它不是 'p-selectButton' 的已知 属性。 -ngx-formly
Can't bind to 'options' since it isn't a known property of 'p-selectButton'. -ngx-formly
我正在为我的 angular 5 应用程序使用 ngx-formly。我创建了共享模块并使用 formly-select 按钮组件来显示一些字段。以下是我面临的错误。谁能帮帮忙。
1. If 'p-selectButton' is an Angular component and it has 'options' input, then verify that it is part of this module.
2. If 'p-selectButton' 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-selectButton
styleClass="formly-select-button-style"
[ERROR ->][options]="selectButtonOptions | async" [dataKey]="dataKey" [optionLabel]="optionLabel"
[fo"): ng:///SharedModule/FormlySelectButtonComponent.html@19:10
Can't bind to 'dataKey' since it isn't a known property of 'p-selectButton'.
注意:我已经在 Shared.module.ts 文件中声明了 formly 模块,如下所示
import {FormlyModule, FormlyFieldConfig } from '@ngx-formly/core';
并且在进口
@NgModule({
imports: [
CommonModule,
PanelModule,
AccordionModule,
MessagesModule,
MessagesModule,
MenuModule,
ButtonModule,
FormlyModule.forRoot({
types: [
{ name: 'input', component: FormlyFieldInputComponent },
{ name: 'selectbutton', component: FormlySelectButtonComponent },
],
还有我的声明
declarations: [
LoaderComponent,
CollectionPanelBoxComponent,
AccordionHeaderEmptyComponent,
FormlySelectButtonComponent,
FormlyFieldInputComponent
],
我的导出
exports: [
AccordionHeaderEmptyComponent,
FormlyModule
]
不确定我做错了什么。
经过漫长的一天,我终于找到了答案。
第 1 步: 如果您使用的是共享模块。确保你已经在三个地方导入了必要的模块。
在Shared.module.ts代码中:
import {
AccordionModule,
ButtonModule, // First declaration point
DataTableModule,
SelectButtonModule,
} from 'primeng/primeng';
同一文件中的第二个声明点
@NgModule({
imports: [
CommonModule,
InputTextModule,
AccordionModule,
ReactiveFormsModule,
MenuModule,
DataTableModule,
ButtonModule, // second declaration point
],
第三个申报点:
exports: [
CommonModule,
ReactiveFormsModule,
PanelModule,
AccordionModule,
LoaderComponent,
MessagesModule,
MenuModule,
InputTextModule,
ButtonModule, // third declaration point
DataTableModule,
DropdownModule,
CollectionPanelBoxComponent,
AccordionHeaderEmptyComponent,
FormlyModule
]
如果一切都像上面那样声明。
第 2 步:
然后检查 primeng 文档。在我的例子中,我使用了
"primeng":"^4.3.0",
注意:您必须使用按钮 pButton 而不是
<button pButton type="button" label="Click" ></button>
<p-button label="Click" ></p-button>
这肯定会解决这个问题。希望它能帮助别人。
我正在为我的 angular 5 应用程序使用 ngx-formly。我创建了共享模块并使用 formly-select 按钮组件来显示一些字段。以下是我面临的错误。谁能帮帮忙。
1. If 'p-selectButton' is an Angular component and it has 'options' input, then verify that it is part of this module.
2. If 'p-selectButton' 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-selectButton
styleClass="formly-select-button-style"
[ERROR ->][options]="selectButtonOptions | async" [dataKey]="dataKey" [optionLabel]="optionLabel"
[fo"): ng:///SharedModule/FormlySelectButtonComponent.html@19:10
Can't bind to 'dataKey' since it isn't a known property of 'p-selectButton'.
注意:我已经在 Shared.module.ts 文件中声明了 formly 模块,如下所示
import {FormlyModule, FormlyFieldConfig } from '@ngx-formly/core';
并且在进口
@NgModule({
imports: [
CommonModule,
PanelModule,
AccordionModule,
MessagesModule,
MessagesModule,
MenuModule,
ButtonModule,
FormlyModule.forRoot({
types: [
{ name: 'input', component: FormlyFieldInputComponent },
{ name: 'selectbutton', component: FormlySelectButtonComponent },
],
还有我的声明
declarations: [
LoaderComponent,
CollectionPanelBoxComponent,
AccordionHeaderEmptyComponent,
FormlySelectButtonComponent,
FormlyFieldInputComponent
],
我的导出
exports: [
AccordionHeaderEmptyComponent,
FormlyModule
]
不确定我做错了什么。
经过漫长的一天,我终于找到了答案。
第 1 步: 如果您使用的是共享模块。确保你已经在三个地方导入了必要的模块。
在Shared.module.ts代码中:
import {
AccordionModule,
ButtonModule, // First declaration point
DataTableModule,
SelectButtonModule,
} from 'primeng/primeng';
同一文件中的第二个声明点
@NgModule({
imports: [
CommonModule,
InputTextModule,
AccordionModule,
ReactiveFormsModule,
MenuModule,
DataTableModule,
ButtonModule, // second declaration point
],
第三个申报点:
exports: [
CommonModule,
ReactiveFormsModule,
PanelModule,
AccordionModule,
LoaderComponent,
MessagesModule,
MenuModule,
InputTextModule,
ButtonModule, // third declaration point
DataTableModule,
DropdownModule,
CollectionPanelBoxComponent,
AccordionHeaderEmptyComponent,
FormlyModule
]
如果一切都像上面那样声明。
第 2 步:
然后检查 primeng 文档。在我的例子中,我使用了
"primeng":"^4.3.0",
注意:您必须使用按钮 pButton 而不是
<button pButton type="button" label="Click" ></button>
<p-button label="Click" ></p-button>
这肯定会解决这个问题。希望它能帮助别人。