我有一个需要使用的选择下拉菜单选项,类似于jquery select2。我正在使用Angular 2和Laravel作为后端。我遵循本教程:https://www.npmjs.com/package/ng2-select2 而我的选择会加载所有数据,但不会显示自动完成功能,也不会显示搜索内容。我需要我的选择类似于以下示例:https://nejczdovc.github.io/ng2-select2-demo/。
有人可以帮助我吗?这是我的代码。
user.component.html
<div class="row form-row">
<div class="form-group col-md-12">
<label for="id_unity" class="required">Unity:</label>
<select select2 class="select2" id="id_unity" name="id_unity" [(ngModel)]="person.id_unity">
<option *ngFor="let item of unityList" value="{{item.id_unity}}">{{item.name_unity}}
</option>
</select>
</div>
app.module.ts
从'ng2-select2'导入{Select2Module};
@NgModule({ 进口:[ ...., 选择2模块 ], ... })