问题描述
我正在使用npm的date-time-picker程序包,特别是时间选择器,但是我需要使hour和min字段仅接受数字,显然该库无法像这样工作,并且无法对其进行配置,因此,我试图动态添加我已经在使用的指令,但该指令未执行。我希望有人可以帮助我该怎么做,或者有什么办法可以更好地利用该库。
我附上了用于添加指令的代码
ngAfterViewChecked(): void {
this.addDirective();
}
flag: boolean = false;
addDirective() {
try {
const input1 = document.getElementsByClassName(
'owl-dt-timer-input'
)[0];
if (input1 && !this.flag) {
console.log('existe input');
input1.setAttributeNS(null,'numberValidator','true');
this.flag = true;
}
} catch (error) {
console.log('Ocurrio un error in ngAfterViewChecked ==> ',error);
}
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)