使用Angular 6,我在将Angular与Observable和nb-input一起正式使用时遇到了问题。 问题:在可观察的情况下不显示数据,但在正确显示数组数据时没有出现任何问题`
<div class="d-flex">
<input type="text" nbInput fullWidth [fieldSize]="'small'" placeholder="Search"
(input)="ngSelect.filter($event.target.value)"/>
<span nbInput
class="d-flex">
<tc-icon class="my-auto" [name]="'search'"></tc-icon>
</span>
</div>
</ng-template>
</ng-select>`
export class FormlySelect extends Field {
@ViewChild('ngSelect', { read: ViewContainerRef }) ngSelect: ViewContainerRef;
get items() {
if (!(this.to.options instanceof Observable)) {
return of(this.to.options);
}
return this.to.options;
}
}
{
className: 'col-12 col-sm-4',
key: 'reason',
type: 'ng-select',
templateOptions: {
label: 'Reason',
options: [
{
'id': 1,
'name': 'Dummy Dummy Dummy',
'unit': {
'id': 1,
'name': '215',
'buliding': '1'
},
'requesterType': 'Resident'
},
{
'id': 2,
'name': 'Felipe Perkins',
'unit': {
'id': 2,
'name': '216',
'buliding': '1'
},
'requesterType': 'Applicant'
},],
bindValue: 'id',
bindLabel: 'name',
},
},