微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Angular - 在 FormControl 上防止 Internet Explorer 缓存

如何解决Angular - 在 FormControl 上防止 Internet Explorer 缓存

我在 Internet Explorer 上使用 FormControl 时遇到问题,目前我还没有找到可行的解决方案。我有一个输入组件,它使用 FormControl 传递的值呈现。问题是,例如,如果我删除屏幕上输入的内容并刷新页面,则渲染组件时没有内容,在实例化组件时传递给 formControl 的值被忽略。>

我知道如果按 Ctrl + f5 刷新页面会按预期工作,但是我如何防止 Internet Explorer 缓存行为?

这是一个最小的、可重复的示例:

我的输入组件

@Component({
  selector: 'app-input-component',template: ` <input type="text" [formControl]="inputControl" autocomplete="off"/> `,})
export class InputComponentComponent implements OnInit {
  @input() inputControl: AbstractControl;
  
  constructor() {}

  ngOnInit() {}
}

使用我的输入组件的组件

@Component({
  selector: 'app-root',template: `<app-input-component [inputControl]="inputControl"></app-input-component>`,})
export class AppComponent implements OnInit {
  inputControl = new FormControl('21/09/1999');

  constructor() {}

  ngOnInit() {}
}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。