-2

Angular 8 openlayers app works in every browser except Edge and IE

On Polyfills.ts uncommented import 'classlist.js'; // Run npm install --save classlist.js. run the specified command

get this error on edge

ngErrorLogger: function() { [native code] } number: -2146823281 stack: "TypeError: Unable to get property 'lock' of undefined or null reference at AppComponent (https://cm-portimao.pt/infomap/main.js:435:9) at createClass (https://cm-portimao.pt/infomap/vendor.js:59268:13) at createDirectiveInstance (https://cm-portimao.pt/infomap/vendor.js:59145:5) at createViewNodes (https://cm-portimao.pt/infomap/vendor.js:67505:21) at createRootView (https://cm-portimao.pt/infomap/vendor.js:67419:5) at callWithDebugContext (https://cm-portimao.pt/infomap/vendor.js:68427:9) at debugCreateRootView (https://cm-portimao.pt/infomap/vendor.js:67937:5) at ComponentFactory_.prototype.create (https://cm-portimao.pt/infomap/vendor.js:58624:9)...

proto: Error

i did a ng build my tsconfig.json is

    {
  "compileOnSave": false,
  "compilerOptions": {
    "baseUrl": "./",
    "outDir": "./dist/out-tsc",
    "sourceMap": true,
    "declaration": false,
    "module": "es2015",
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "importHelpers": true,
    "target": "es5",
    "typeRoots": [
      "node_modules/@types"
    ],
    "lib": [
      "es2018",
      "dom"
    ]
  }
}
  • 1
    About the Angular 7 openlayers, do you mean [this one](https://github.com/Viglino/ol-ext-angular). By default in angular version 8, differential loading for ng build is enabled. However for `ng test` and `ng serve`, it only generates a single ES2015 build which cannot run in IE11. So, if you are using Angular 8, we need to configure ES5 for it. you could refer to [this thread](https://stackoverflow.com/questions/56379067/how-do-i-support-internet-explorer-in-an-angular-8-application). – Zhi Lv Oct 17 '19 at 15:09
  • Ive edited my question and im doing ng build already, not serve, there is my tsconfig.json also. – Pedro Encarnação Oct 18 '19 at 10:47
  • I have tested [this sample](https://github.com/Viglino/ol-ext-angular), after uncomment the related polyfill in the polyfills.ts file ([polyfill content](http://jsfiddle.net/ckgewnjo/)), it works well on my machine. you could check it. If still not working, can you post the Enough code to reproduce the problem as in [Minimal, Complete, and Verifiable example](https://stackoverflow.com/help/mcve). – Zhi Lv Oct 18 '19 at 14:19

1 Answers1

0

Ok, located the problem. I was trying to force the screen to stay at landscape on mobile, so i was following an tutorial that told me to add

screen.orientation.lock('landscape');

to the code, it didnt work, but everything else was ok, no error, so i continued the app and left that for later. After some reading i saw that this was discontinued and it never worked in ie or edge, so theres my error.