【发布时间】:2018-12-28 23:38:23
【问题描述】:
这是我的代码: 我想在我的表单上添加 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>
我的错误是:无法绑定到“项目”,因为它不是“ng-select”的已知属性为什么?????
你能帮帮我吗? 非常感谢!
【问题讨论】:
-
是否在您的 ComponentsModule 中声明了 modaltest.component?
-
@GianlucaParis No...
-
组件在哪个模块中?
-
您需要将
NgSelectModule导入您的根模块(在Angular CLI 项目中通常称为app.module.ts)||将NgSelectModule导入到您声明modaltest.component.ts的特定模块中。我建议将其导入根目录,以便整个应用程序都可以使用该包。
标签: angular jquery-select2 angular6