这是我的代码:
我想在我的表格上添加https://github.com/ng-select/ng-select多选标签输入。
组件.模块.ts:
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { HttpClientModule } from '@angular/common/http';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { NgSelectModule } from '@ng-select/ng-select';
@NgModule({
imports: [
CommonModule,
HttpClientModule,
FormsModule,
ReactiveFormsModule,
NgSelectModule,
]
})
export class ComponentsModule { }
我的 modaltest.component.html
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
<label class="control-label">
<strong>Gusti:</strong>
</label>
[ERROR] ---> <ng-select [items]="testitems" [hideSelected]="true" multiple="true" bindLabel="text1"></ng-select>
</div>
我的错误是:无法绑定到“items”,因为它不是“ng-select”的已知属性为什么???
你能帮助我吗?
多谢!
你必须导入NgSelectModule
在声明你的模块中ModalTestComponent
,或者,如果您的ComponentsModule
是一个包装器,您应该导入声明的模块ModalTestComponent
在里面;这边走:
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { HttpClientModule } from '@angular/common/http';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { NgSelectModule } from '@ng-select/ng-select';
// add this line
import { ModuleThatDeclaresModalTest } from 'path/to/module'
@NgModule({
imports: [
CommonModule,
HttpClientModule,
FormsModule,
ReactiveFormsModule,
NgSelectModule,
// and this line
ModuleThatDeclaresModalTest
]
})
export class ComponentsModule { }
作为替代方案,正如@Narm所说,您可以导入NgSelectModule
在你的AppModule
,以便所有子模块都可以使用它。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)