David Pfeffer
David Pfeffer

Reputation: 39871

Coding against Angular 1, for easiest upgrade to Angular 2?

I'm starting a new greenfield development for an app (actually an Ionic app) that is not expected to be deployed for a while, but for a variety of reasons I cannot yet use Angular 2.

For the time being, I'll be writing in TypeScript generating ES2015, passing through Babel to convert to ES5, and writing against Angular 1.

I'd like to easily upgrade in the future to Angular 2. What are the best practices for my code to ensure as easy an upgrade path as possible to ng2?

Upvotes: 4

Views: 154

Answers (3)

Angular University
Angular University

Reputation: 43127

The simplest would be to dive into ng-forward, the offical default solution for those that want to write Angular 2.x style code in Angular 1.x.

Then later when you want to migrate to Angular 2, introduce ng-upgrade.

It should be a lot easier to use ng-upgrade if you follow the development practices since the beginning of ng-forward.

Upvotes: 3

pbo
pbo

Reputation: 193

I would definitely use jspm as a package manager and SystemJS as a module loader. The SystemJS module loader is built on top of ES6 module loader and can be used with Angular 1.x.

With the ability of an additional CSS plugin, SystemJS also load CSS files for each individual component.

Like that you can write Angular 1.x components, that can be easily upgraded to Angular 2 Components in the future.

Upvotes: 2

Mark Rajcok
Mark Rajcok

Reputation: 364747

This presentation, Refactoring To Components, by Tero Parviainen, Angular Meetup Berlin #25, should be of interest to you. The presenter discusses how to refactor Angular 1 code (in an iterative way) to get it ready for porting to Angular 2. I assume if you follow the patterns and techniques he presents, your Angular 1 app will be much easier to upgrade later to Angular 2.

Upvotes: 2

Related Questions