javascript - 以角度 10 提交表单后无法清除 ngx-mat-intl-tel-input
问题描述
<ngx-mat-intl-tel-input [preferredCountries]="['in', 'us', 'gb' ]" [enableSearch]="true" [enablePlaceholder]="true"
#phoneNumber="ngModel" [(ngModel)]="Sms" name = "Sms" required>
</ngx-mat-intl-tel-input>
解决方案
您可以尝试手动清除输入。例如:
@ViewChild(NgxMatIntlTelInputComponent, {static: true}) phoneInput: NgxMatIntlTelInputComponent;
然后是这样的:
if (this.phoneInput) {
const telInput = document.querySelector(`#${this.phoneInput.id} input[type="tel"]`);
if (telInput) {
(<any>telInput).value = '';
}
}
推荐阅读
- react-native - React Navigation:如何在按下 TouchableOpacity 时传递道具并导航到其他屏幕
- android - 如何使用 DragListener 收听拖动,但将点击传递到下面的视图?
- python-3.x - 为什么我使用 tensorflow 进行的 DQN 训练每次迭代都会变慢?
- javascript - 使用 nicescroll 切换水平滚动元素上的类
- spring-security - Spring Security XML 配置登录问题
- python - 将 urllib2 python 代码转换为使用 urllib 模块
- google-chrome - 当我打开开发者工具(检查元素)时,谷歌浏览器会自动重新加载页面
- python - Python win32 api drawText() 和 SetTextColor
- javafx - 如何在 IntelliJ 中安装 ControlsFX?
- sql - 以正确的持续时间转换 Julien 日期和时间戳