Introduction to Angular 2 in JavaScript/ES5 – Part 1

This is the first of a new mini-series of videos on Angular 2 using ES5 i.e. the “classic” JavaScript syntax.

In this first part we see how to write a first Angular 2 Component, and introduce the concepts of Template, Metadata, HTML Plus, and the bootstrap method.

You can download the starting project mentioned in the video here:

Interested in my upcoming full course on Angular 2? Pre-register here.

Angular 2 in ES6 without decorators

With Angular 2 now in beta, it’s definitely time to start playing with it. One of my first questions was: what language to use? The first example in the Angular 2 website says

While this example uses TypeScript, Angular works equally well with ES5, ES6 and Dart as well.

Those are the languages officially supported by Angular 2. Dart has lost most of its appeal since they declared it won’t be integrated into Chrome, so I’ll just gloss over it.

Angular 2 itself is written in TypeScript, and so are most of the official examples available so far. I do like TypeScript and it is arguably the best choice for large projects. However it may be overkill for smaller apps or just some quick experiments. Configuring type definitions for existing JavaScript libraries in particular can be a bit of a pain.

ES5 is just… old. If we use JavaScript for a new project today we may as well start with ES6. Surprisingly though I could find very few Angular 2 examples in ES6. And those few typically use decorators, a language feature that is not actually in the ES6 standard but one proposed for ES7. As a result it’s only partially supported by Babel for example.

So, is it actually possible to write Angular 2 components in “pure” ES6, with code similar to the TypeScript examples but without types and decorators?
Continue reading

How to create iOS certificates for Ionic Package on Windows/Linux

With the recent announcement of Ionic Package you can now build your Ionic app for iOS even without a Mac.

However you still need to set up Certificates and Provisioning Profiles in the Apple Developer Member Center, then upload them to your account before you can build anything.

The Ionic Package documentation explains how to set up iOS Credentials using OS X. But what if you don’t have access to a Mac? That’s supposed to be one advantage of Ionic Package: it lets you build iOS apps without a Mac, right?

Luckily it’s entirely possible to set up the certificates using Windows or Linux as well. Here’s how.
Continue reading

How to use JavaScript 2015 (ES6) now in your Ionic app

ECMAScript 2015 has finally been approved a few days ago. The new JavaScript standard – also known as ES6 – introduces a wealth of new features, from arrow functions and classes to block-scoped variables and modules, and many more.

JavaScript 2015 is a much richer, more modern language that tackles many of the shortcomings of earlier versions and is a lot more fun to work with. Shame that we now need to wait some time before all the major browsers will support the new standard… Or do we?

Well, thankfully we don’t. We can use ES6 right now. There are a few transpilers that can take ES6 code and translate it into ES5 code that happily runs on existing browsers. In this post, I’ll show you how to configure an Ionic project to use the Babel compiler.

Continue reading