我正在使用ngx-bootstrap typehead和angular 6 reactive form控件。它在除了internet explorer 11之外的所有浏览器上都工作得很好。每当没有选择typehead建议列表的选项时,我都会再次单击焦点之外的typehead控件。您可以在以下位置看到相同的问题
https://valor-software.com/ngx-bootstrap/#/typeahead#reactive-forms
在这里,我已经确定了反应式表单的相同问题。
如果有人对此有任何选择,请让我知道。
谢谢阿莫尔·拉吉汉斯。
发布于 2019-09-16 11:57:05
我在IE中遇到了同样的行为,并创建了一个快速解决方法。
import { Directive, Input } from '@angular/core';
import { TypeaheadDirective } from 'ngx-bootstrap';
const isIE = navigator.userAgent.indexOf('MSIE')!==-1 || navigator.appVersion.indexOf('Trident/') > -1;
@Directive({selector: '[typeaheadIeFix]', exportAs: 'bs-typeahead'})
export class TypeaheadIeFixDirective extends TypeaheadDirective {
private ie_init:boolean = false;
@Input('typeaheadIeFix') typeahead: any;
/**
* when ngModel or formControl is init'ed, it seems to update input value triggering an 'input' event in IE.
* that 'input' event then causes typeahead directive to focus on the bound input and even open its suggestion list if possible.
*/
onInput (e) {
if (isIE && !this.ie_init) {
this.ie_init = true;
return;
}
super.onInput(e);
}
}https://stackoverflow.com/questions/55773043
复制相似问题