[Fixed] Is cordova supporting ES6 and/or Angular2?


I want to create mobile app by using phonegap and I want to use Angular2 that works with ES6. I can’t find any information about that on they official website.
I want to know is it will work or no?


Updated answer 2021

If you’re targeting Android 4.4 (or lower) you can’t use ES6 because it’s not supported unless you use Babel to compile your code (see below). From Android 5.0 the webview is independent from the OS and it’s updated seperately from the OS, so you can use ES6 directly.

You can also check your target OS/browser ES6 support on caniuse.

Original answer

ECMAScript 6 support doesn’t depend on Cordova, is a Webview issue.

If the native Webview where the app will be executed support ES6, you app will be work nice, otherwise doesn’t.

Since the ES6 specification was finally approved on June 17 of this year (2015), the actual support for ES6 of mobile Webview is missing or incomplete.

To run ECMAScript 6 applications today you can use Babel or Traceur compiler, that "compile" your code from ES6 to ES5. This is also the approach used in Angular 2 quickstart (see the traceur import in section "6. Declare the HTML").

So, why don’t you try an Angular 2 generator that include traceur or a web app generator with babel? If you are new to the tools involved, I suggest you to start learning grunt/gulp/bower/yo.

Leave a Reply

(*) Required, Your email will not be published