【发布时间】:2019-03-26 07:13:22
【问题描述】:
我想实现自动完成功能,所以我发现一个相同的选项是使用多选下拉菜单。所以我使用了这个模块-
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 { }
【问题讨论】:
-
您是否在模块配置中为
imports添加了正确的模块?? -
是的,我包括==> import { NgMultiSelectDropDownModule } from 'ng-multiselect-dropdown';在 app.module.ts
-
但我的意思是模块导入,而不是源文件导入......你最好粘贴 app.module.ts
-
尝试从 '@angular/platform-browser' 导入 { BrowserModule },如您的 app.module.ts 中所见,您没有导入通用模块,这些模块对于在功能模块和 BrowserModule 提供启动和运行浏览器应用程序所必需的服务
-
你的
component.html有component.module.ts吗??
标签: angular angular2-services angular2-directives