Bon*_*rco 7 jquery-select2 angular angular6
这是我的代码:我想在我的表单上添加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 { }
Run Code Online (Sandbox Code Playgroud)
我的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>
Run Code Online (Sandbox Code Playgroud)
我的错误是:无法绑定到 'items' 因为它不是 'ng-select' 的已知属性 为什么????
你能帮助我吗?非常感谢!
Gia*_*ris 15
你必须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 { }
Run Code Online (Sandbox Code Playgroud)
作为替代方案,正如@Narm 所说,您可以导入NgSelectModule您的AppModule,以便所有子模块都可以使用它。
| 归档时间: |
|
| 查看次数: |
13994 次 |
| 最近记录: |