
[英]Angular 7, how can I control ng-select options by selecting other ng-select value?
[英]Want to access input element inside ng-select in angular 6 for getting it's value
我正在处理一个项目,我想在 ng-select 中创建一个自定义功能,以便在 ng-select 中输入文本时,它将其附加到绑定项并将其添加为多选。
http://embed.plnkr.co/GLuyC0jpIdiEXB6R4FIa/preview
这是 angular 6 中所需的确切实现
我正在使用 angular v6.0
在 angular 5 中是否还有其他方法可以实现该实现,如上述plunker所示?
对不起,如果有一些错误的问题。 因为我是 Angular 的新手。
提前致谢。
我找到的唯一解决方案是访问ng-select
子项。
我的html:
<ng-select [items]="places"
bindLabel="name"
[(ngModel)]="selected" dropdownPosition="bottom" #ngselect>
<ng-template ng-option-tmp let-item="item" let-index="index">
<b>{{item}}</b>
</ng-template>
</ng-select>
ngselect
- NgSelectComponent
this.myselect.element
- 使用 HTMLElement,在孩子中我们正在寻找我们的<input>
@ViewChild('myngselect') myselect;
myMethod() {
const input = this.myselect.element.children[0].children[0].children[1].children[0];
}
我认为您可以通过使用 ng-select 的 addTag 来实现此功能,
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.