2

I developed a Angular 2 application which doesn't work in Android 4.1.x and more stock browsers.

The only link to Polyfills I have included inside my app is the following:

<script src="node_modules/core-js/client/shim.min.js"></script>

I read Angular2 documentation (here) and I saw that I have to inculde ES6 Polyfill to make it work on Android devices, but I have no idea how to link it. It is included in core-js module, but how to insert it inside the app?

B. Ciervo
  • 135
  • 4
  • 16
  • Were you able to figure out which file for the ployfill to include @B. Ciervo? – PBandJ Mar 08 '17 at 19:28
  • No, but I solved another way... I installed @types/core-js": "^0.9.35" with npm install and changed inside tsconfig.json my target from es6 to es5. Then inserted into "compilerOptions" the following instructions: "typeRoots": [ "../node_modules/@types" ], "types" : [ "core-js" ] and it worked. – B. Ciervo Mar 10 '17 at 09:39
  • Thanks for your solution. Also, was there a reason why you decided to use core-js versus other npm modules, like angular2-ie-shims [link](https://www.npmjs.com/package/angular2-ie9-shims)? I am wondering if the polyfills are any different – PBandJ Mar 10 '17 at 17:58
  • Mmm no, just... I tried and it worked :) did you manage to get it work, too? – B. Ciervo Mar 13 '17 at 08:24
  • ie-shims for internet explorer. core-js also for android4.1+ . but PBandJen answer do not work for me. target already was es5 and typeRoots": [ "../node_modules/@types] i only added "types" : [ "core-js" ] but without success. this angular2 site https://ng-bootstrap.github.io/#/home works fine, but it has hash strategy – dimson d Mar 13 '17 at 13:34
  • Possible duplicate of [Add polyfill code in Angular 2](https://stackoverflow.com/questions/42361941/add-polyfill-code-in-angular-2) – Lucenty Jul 31 '17 at 07:58
  • do you still need help on this? – Manjunath Siddappa Dec 05 '17 at 13:44

2 Answers2

0

You would have to insert that inside your <head>, you can check that it loads by doing a view page source on a computer.

Jean-Baptiste
  • 1,552
  • 1
  • 19
  • 33
0

for example inside your bundle import 'core-js/es6';

dimson d
  • 1,488
  • 1
  • 13
  • 14