这是我的代码:我想在我的表单上添加https://github.com/ng-select/ng-select多选标签输入 .
components.module.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'的已知属性为什么?????
你能帮助我吗?非常感谢!
1 回答
您必须在声明
ModalTestComponent
的模块中导入NgSelectModule
,或者,如果ComponentsModule
是包装器,则应导入声明ModalTestComponent
的模块;这条路:作为替代,正如@Narm所说,您可以在
AppModule
中导入NgSelectModule
,以便所有子模块都可以使用它 .