【问题标题】:Binding not working immediately when value change in Microsoft Edge for Angular 7当 Angular 7 的 Microsoft Edge 中的值更改时,绑定无法立即工作
【发布时间】:2019-02-11 16:33:32
【问题描述】:

在我的 Angular 7 解决方案中,我遇到了 Microsoft Edge 视图中的数据绑定问题/Opera、Chrome 和 Mozilla 等其他浏览器工作正常/。 我的页面包含多个输入元素,如文本框、下拉菜单、单选按钮、日期选择器。每个输入元素上都有 onValueChange 触发器,在控制器 /.ts 文件/中,这些更改是立即的,但视图没有更新。

我添加了双花括号表示法来显示视图中的当前值,但值是空值/或旧值/直到您单击下一个输入/但不是每个输入 - 仅日期选择器或下拉/。 当我尝试在其他浏览器中检查时,在输入值后立即显示值。

我尝试为支持的浏览器添加多个基于 angular 官方网站的 polyfill,但没有任何帮助。

这是我的 tsconfig.json 和 polyfills.ts:

{
"compileOnSave": false,
"compilerOptions": {
"baseUrl": "./",
"importHelpers": true,
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
"module": "es2015",
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "es2015",
"typeRoots": [
"node_modules/@types"
],
"lib": [
  "es2017",
  "dom"
 ]
 }
 }

/** IE9, IE10 and IE11 requires all of the following polyfills. **/
 import 'core-js/es6/symbol';
 import 'core-js/es6/object';
 import 'core-js/es6/function';
 import 'core-js/es6/parse-int';
 import 'core-js/es6/parse-float';
 import 'core-js/es6/number';
 import 'core-js/es6/math';
 import 'core-js/es6/string';
 import 'core-js/es6/date';
 import 'core-js/es6/array';
 import 'core-js/es6/regexp';
 import 'core-js/es6/map';
 import 'core-js/es6/weak-map';
 import 'core-js/es6/set';

/** IE10 and IE11 requires the following for the Reflect API. */
 import 'core-js/es6/reflect';

// Used for browsers without a native support of Custom Elements
import '@webcomponents/custom-elements/custom-elements.min';

import '@ng-select/ng-select/bundles/ng-select.umd.min';

 import 'web-animations-js';  // run `npm install --save web-animations-js`.

有什么方法可以让它在 Edge 上运行吗?

【问题讨论】:

  • 欢迎来到 Stack Overflow!请务必分享相关代码。如果可能的话,分享一个工作的和最小的代码 sn-p 来演示这个问题。

标签: angular internet-explorer cross-browser microsoft-edge angular-elements


【解决方案1】:

尝试参考以下代码:

<input type="text" class="form-control" (input)="onSearchChange($event.target.value)"><br/>
<span>{{ name}}</span>

.ts 文件:

export class AboutComponent implements OnInit {

  name:string;

  constructor() { }

  ngOnInit() {
  }
  onSearchChange(searchValue : string ) {  
    console.log(searchValue);
    this.name = searchValue;
  }
}

它在我这边运行良好(Edge 42.17134.1.0),像这样:

如果仍然无法正常工作,您能否像Minimal, Complete, and Verifiable example 一样发布足够的代码来重现问题。此外,您还可以查看 Edge 浏览器版本。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-09-28
    • 1970-01-01
    • 2015-09-07
    • 2020-07-17
    • 2019-11-10
    • 1970-01-01
    • 2016-05-24
    • 2014-05-12
    相关资源
    最近更新 更多