I'm using Ionic 2 to develop a mobile application. The following are the information of my ionic installation:
- Cordova CLI: 6.3.1
- Ionic Framework Version: 2.0.0-rc.4
- Ionic CLI Version: 2.1.18
- Ionic App Lib Version: 2.1.9
- Ionic App Scripts Version: 0.0.47
- ios-deploy version: Not installed
- ios-sim version: Not installed
- OS: Windows 10
- Node Version: v6.9.2
- Xcode version: Not installed
I have an extension.ts
file that contains various extensions of predefined types of TypeScript/JavaScript, including the following class:
export {};
declare global {
interface Navigator {
currentLang() : string;
}
}
Navigator.prototype.currentLang = function() {
var userLang = navigator.language.split('-')[0];
userLang = /(en|it)/gi.test(userLang) ? userLang : 'en';
return userLang;
};
When I run the command ionic serve
the google developer console shows the following error:
TypeError: navigator.currentLang is not a function
What could be the problem? Am I forgetting something?
extension.ts
? – Nitzan Tomernavigator.currentLang
inapp.componet.ts
inside theplatform.ready().then(...)
callback. I'm importing the extensions at the top ofapp.componet.ts
using the lineimport { } from '../extensions'
; – Balthier