在自动完成下拉列表中显示的数据:
users = [{"user_id":0,"name":"name1"},
{"user_id":1,"name":"name2"},
{"user_id":2,"name":"name3"}];
显示的 UI 模板代码ng2-tag-input
<tag-input [ngModel]="selectedUsers" [onlyFromAutocomplete]="true">
<tag-input-dropdown [showDropdownIfEmpty]="true" [autocompleteItems]="users" [identifyBy]="'user_id'" [displayBy]="'name'">
</tag-input-dropdown>
</tag-input>
模态对话框的 UI 模板是:-
<div bsModal #largeModal="bs-modal" [config]="{backdrop: 'static'}" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog modal-lg modal-primary" role="document">
<div class="modal-content">
<div class="modal-body">
<div class="meeting-form m-xl-1">
<div class="row">
<div class="col-sm-6">
<div class="form-group">
<label for="name">Users</label>
<tag-input [(ngModel)]="selectedUsers" [onlyFromAutocomplete]="true">
<tag-input-dropdown [showDropdownIfEmpty]="true" [autocompleteItems]="users" [identifyBy]="'user_id'" [displayBy]="'name'">
</tag-input-dropdown>
</tag-input>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- /.modal-content -->
</div>
<!-- /.modal-dialog -->
</div>
在上面的模态对话框ng2-tag-input
中不起作用。