更改检测在 Firefox 中不正确 运行

Change detection isn't run properly in Firefox

在 Chrome 中,一切正常,但在 Firefox 中,绑定永远不会更新。

问题似乎与 core-js and/or zone.js:

有关

这些问题已修复,但我使用的是最新版本的 angular (v2.4.9),但它不起作用。

我导入polyfill.ts,即:

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/set';
import 'core-js/es6/reflect';

import 'core-js/es7/reflect';
import 'zone.js/dist/zone';

main.ts。我尝试按照其中一张 Github 票中的建议将 zone.js 导入放在 core-js 导入之前,但它不起作用。

我的 index.html 中是否需要包含另一个 polyfill 或 link?

编辑 #1

它似乎在 Firefox 中实际工作了 50%。如果我刷新页面,它会每隔一段时间正确呈现页面。当它不起作用时,绝对没有绑定在起作用;不执行事件回调,{{ ... }} 不呈现绑定等

编辑 #2

这个错误实际上是由 Polymer's platform.js (polyfills for Polymer) which I am linking in my index.html. If I remove it, the bindings start to work again. I have implemented this Midi synth 在我的应用程序中引起的,它使用了 Polymer,这需要 platform.js。所以看起来 platform.js 和 Firefox 中的 Angular2 有冲突。有什么办法可以解决这个冲突吗?

我搜索了一下。

显然,Firefox 缓存数据,因此您的问题。

很多人似乎对使用 Firefox 开发 Angular 感到恼火。

我发现了这个 code,它没有解决这个人的问题,但应该可以解决你的问题:

$rootScope.$on('$viewContentLoaded', function() {
  $templateCache.removeAll();
});  

如果没有,我建议您查看缓存和 Angular2

由于还没有找到解决方案,我暂时采用手动触发更改检测(当用户代理是 Firefox 时)。

用法:

import { ApplicationRef } from '@angular/core';
...
constructor(private applicationRef: ApplicationRef) {}
...
setInterval(() => this.applicationRef.tick(), 100);