无法绑定到 'placeholder',因为它不是 'ng-multiselect-dropdown' 的已知 属性
Can't bind to 'placeholder' since it isn't a known property of 'ng-multiselect-dropdown'
我想实现自动完成功能,所以我发现一个相同的选项是使用 multi-select 下拉菜单。所以我使用了这个模块 -
https://www.npmjs.com/package/ng-multiselect-dropdown
但是在执行同上之后,我得到了这些错误 -
错误-
ERROR Error: Uncaught (in promise): Error: Template parse errors:
Can't bind to 'placeholder' since it isn't a known property of 'ng-
multiselect-dropdown'.
1. If 'placeholder' is an Angular directive, then add 'CommonModule'
to the '@NgModule.imports' of this component.
2. To allow any property add 'NO_ERRORS_SCHEMA' to the
'@NgModule.schemas' of this component. ("
<ng-multiselect-dropdown
[ERROR ->][placeholder]="'custom placeholder'"
[data]="dropdownList"
[(ngModel)]="selectedItems"
"): ng:///AdminLayoutModule/HierarchySearchComponent.html@7:0
当我在 component.html 中评论占位符时,我得到这个错误 -
Can't bind to 'data' since it isn't a known property of 'ng-
multiselect-dropdown'.
1. If 'data' is an Angular directive, then add 'CommonModule' to the
'@NgModule.imports' of this component.
2. To allow any property add 'NO_ERRORS_SCHEMA' to the
'@NgModule.schemas' of this component.
"
<ng-multiselect-dropdown
[placeholder]="'custom placeholder'"
[ERROR ->][data]="dropdownList"
[(ngModel)]="selectedItems"
[settings]="dropdownSettings"
"): ng:///AdminLayoutModule/HierarchySearchComponent.html@8:2
类似的错误一直持续到最后一个属性。
更新
app.module.ts
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { HttpModule } from '@angular/http';
import { RouterModule } from '@angular/router';
import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
import { AppRoutingModule } from './app.routing';
import { ComponentsModule } from './components/components.module';
import { AppComponent } from './app.component';
import { AdminLayoutComponent } from './layouts/admin-layout/admin-layout.component';
//------------- Imported Modules -------------------------
import { NgMultiSelectDropDownModule } from 'ng-multiselect-dropdown';
import { CommonModule } from '@angular/common';
@NgModule({
imports: [
BrowserAnimationsModule,
FormsModule,
HttpModule,
ComponentsModule,
RouterModule,
AppRoutingModule,
NgbModule.forRoot(),
NgMultiSelectDropDownModule.forRoot(),
CommonModule,
],
declarations: [
AppComponent,
AdminLayoutComponent,
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
HierarchySearchComponent - 这是您正在使用的组件 ng-multiselect-dropdown
。
所以你可能 HierarchySearch.module.ts.
您只需从 imports:[] 中删除 NgMultiSelectDropDownModule.forRoot() 并在 HierarchySearch.module.ts[ 中导入=23=]。
它会起作用的。!
通常,当您错过某些导入时会出现此错误。如果缺少,请添加这些行:
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule } from '@angular/forms';
在导入所有组件的 ComponentsModule 中添加多 select 导入。它对我有用。
检查你是否导入了 NgMultiSelectDropDownModule 导入到 module.ts
import { NgMultiSelectDropDownModule } from 'ng-multiselect-dropdown';
@NgModule({
imports: [
NgMultiSelectDropDownModule
],
我也在使用 angular 7 但是我的问题已经解决了。我只是导入 NO_ERRORS_SCHEMA
并包含在包含 ng-multiselect-dropdown
模块的同一模块中 @NgModule
:
import { NgModule ,NO_ERRORS_SCHEMA} from '@angular/core';
import { FormsModule } from '@angular/forms';
@NgModule({
imports: [
CommonModule,
FormsModule,
AngularMultiSelectModule,
],
schemas:[NO_ERRORS_SCHEMA],
})
export class SettingsModule { }
我遇到了这个问题并解决了
添加
import { NgMultiSelectDropDownModule } from 'ng-multiselect-dropdown';
和
@NgModule({
imports: [
NgMultiSelectDropDownModule
]
})
到 xxxx.module.ts 导入组件的文件而不是 app.module.ts 文件
我想实现自动完成功能,所以我发现一个相同的选项是使用 multi-select 下拉菜单。所以我使用了这个模块 -
https://www.npmjs.com/package/ng-multiselect-dropdown
但是在执行同上之后,我得到了这些错误 -
错误-
ERROR Error: Uncaught (in promise): Error: Template parse errors:
Can't bind to 'placeholder' since it isn't a known property of 'ng-
multiselect-dropdown'.
1. If 'placeholder' is an Angular directive, then add 'CommonModule'
to the '@NgModule.imports' of this component.
2. To allow any property add 'NO_ERRORS_SCHEMA' to the
'@NgModule.schemas' of this component. ("
<ng-multiselect-dropdown
[ERROR ->][placeholder]="'custom placeholder'"
[data]="dropdownList"
[(ngModel)]="selectedItems"
"): ng:///AdminLayoutModule/HierarchySearchComponent.html@7:0
当我在 component.html 中评论占位符时,我得到这个错误 -
Can't bind to 'data' since it isn't a known property of 'ng-
multiselect-dropdown'.
1. If 'data' is an Angular directive, then add 'CommonModule' to the
'@NgModule.imports' of this component.
2. To allow any property add 'NO_ERRORS_SCHEMA' to the
'@NgModule.schemas' of this component.
"
<ng-multiselect-dropdown
[placeholder]="'custom placeholder'"
[ERROR ->][data]="dropdownList"
[(ngModel)]="selectedItems"
[settings]="dropdownSettings"
"): ng:///AdminLayoutModule/HierarchySearchComponent.html@8:2
类似的错误一直持续到最后一个属性。
更新
app.module.ts
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { HttpModule } from '@angular/http';
import { RouterModule } from '@angular/router';
import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
import { AppRoutingModule } from './app.routing';
import { ComponentsModule } from './components/components.module';
import { AppComponent } from './app.component';
import { AdminLayoutComponent } from './layouts/admin-layout/admin-layout.component';
//------------- Imported Modules -------------------------
import { NgMultiSelectDropDownModule } from 'ng-multiselect-dropdown';
import { CommonModule } from '@angular/common';
@NgModule({
imports: [
BrowserAnimationsModule,
FormsModule,
HttpModule,
ComponentsModule,
RouterModule,
AppRoutingModule,
NgbModule.forRoot(),
NgMultiSelectDropDownModule.forRoot(),
CommonModule,
],
declarations: [
AppComponent,
AdminLayoutComponent,
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
HierarchySearchComponent - 这是您正在使用的组件 ng-multiselect-dropdown
。
所以你可能 HierarchySearch.module.ts.
您只需从 imports:[] 中删除 NgMultiSelectDropDownModule.forRoot() 并在 HierarchySearch.module.ts[ 中导入=23=]。
它会起作用的。!
通常,当您错过某些导入时会出现此错误。如果缺少,请添加这些行:
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule } from '@angular/forms';
在导入所有组件的 ComponentsModule 中添加多 select 导入。它对我有用。
检查你是否导入了 NgMultiSelectDropDownModule 导入到 module.ts
import { NgMultiSelectDropDownModule } from 'ng-multiselect-dropdown';
@NgModule({
imports: [
NgMultiSelectDropDownModule
],
我也在使用 angular 7 但是我的问题已经解决了。我只是导入 NO_ERRORS_SCHEMA
并包含在包含 ng-multiselect-dropdown
模块的同一模块中 @NgModule
:
import { NgModule ,NO_ERRORS_SCHEMA} from '@angular/core';
import { FormsModule } from '@angular/forms';
@NgModule({
imports: [
CommonModule,
FormsModule,
AngularMultiSelectModule,
],
schemas:[NO_ERRORS_SCHEMA],
})
export class SettingsModule { }
我遇到了这个问题并解决了 添加
import { NgMultiSelectDropDownModule } from 'ng-multiselect-dropdown';
和
@NgModule({
imports: [
NgMultiSelectDropDownModule
]
})
到 xxxx.module.ts 导入组件的文件而不是 app.module.ts 文件