1

在特定的项目框架中,我们使用 WCMJahia来集成我们的 Angular 5 模块,以将它们显示在站点的各个页面中。

我们必须恢复的 WCM jahia 属性以集成它们并在我们的模块 Angular 5 中使用它们,它包括恢复一些数据的键/值列表。

我们暂时设法编写了这个解决方案,并且它可以工作(IE9 除外):

文件名.jsp

<script type="text/javascript" src="...../dist/polyfills.bundle.js"> </script>
<script type="text/javascript" src="...../dist/vendor.bundle.js"> </script>
<script type="text/javascript" src="...../dist/main.bundle.js"> </script>

<script>
    document.addEventListener("DOMContentLoaded", function() {
        var myProperties = {
            //For example
            codes: "codes",
            labels: "labels"
        };
        window.run(myProperties);
    });
</script>

<app-myApp></app-myApp>

main.ts

window['run'] = (myProperties) => {
  platformBrowserDynamic([
    {
      provide: 'myProperties',
      useValue: myProperties
    },
    ...
  ])
    .bootstrapModule(AppModule)
    .catch(err => console.log(err));
};

问题是,如果我们使用 IE9(我们无法引导 Angular 5 应用程序),此解决方案将不起作用,因为window['run']...

问题是,是否有另一种方法可以从 JAHIA Jsp 中检索变量/值列表并将其注入到provide之前的bootstrapModuleAngular 中?

4

1 回答 1

0

经过一番研究和几滴汗水,终于找到了解决方案。

这包括取消注释与IE9IE10IE11浏览器polyfills.ts相关的文件部分。

polyfills.ts

/***************************************************************************************************
 * BROWSER POLYFILLS
 */

/** 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';

我希望这可以帮助遇到同样情况的人。

于 2018-03-29T17:43:56.523 回答