include ../../../../_includes/_util-fns :marked Having an existing Angular 1 application doesn't mean that we can't begin enjoying everything Angular 2 has to offer. That's beause Angular 2 comes with built-in tools for migrating Angular 1 projects over to the Angular 2 platform. Some applications will be easier to upgrade than others, and there are ways in which we can make it easier for ourselves. It is possible to prepare and align Angular 1 applications with Angular 2 even before beginning the upgrade process. These preparation steps are all about making the code more decoupled, more maintainable, and up to speed with modern development tools. That means the preparation work will not only make the eventual upgrade easier, but will also generally improve our Angular 1 applications. One of the keys to a successful upgrade is to do it incrementally, by running the two frameworks side by side in the same application, and porting Angular 1 components to Angular 2 one by one. This makes it possible to upgrade even large and complex applications without disrupting other business, because the work can be done collaboratively and spread over a period of time. The `upgrade` module in Angular 2 has been designed to make incremental upgrading seamless. 1. [Preparation](#preparation) 1. [Following The Angular Style Guide](#following-the-angular-style-guide) 2. [Using a Module Loader](#using-a-module-loader) 3. [Migrating to TypeScript](#migrating-to-typescript) 4. [Using Component Directives](#using-component-directives) 2. [Upgrading with The Upgrade Adapter](#upgrading-with-the-upgrade-adapter) 1. [How The Upgrade Adapter Works](#how-the-upgrade-adapter-works) 2. [Bootstrapping Hybrid Angular 1+2 Applications](#bootstrapping-hybrid-angular-1-2-applications) 3. [Using Angular 2 Components from Angular 1 Code](#using-angular-2-components-from-angular-1-code) 4. [Using Angular 1 Component Directives from Angular 2 Code](#using-angular-1-component-directives-from-angular-2-code) 5. [Projecting Angular 1 Content into Angular 2 Components](#projecting-angular-1-content-into-angular-2-components) 6. [Transcluding Angular 2 Content into Angular 1 Component Directives](#transcluding-angular-2-content-into-angular-1-component-directives) 7. [Making Angular 1 Dependencies Injectable to Angular 2](#making-angular-1-dependencies-injectable-to-angular-2) 8. [Making Angular 2 Dependencies Injectable to Angular 1](#making-angular-2-dependencies-injectable-to-angular-1) 3. [PhoneCat Preparation Tutorial](#phonecat-preparation-tutorial) 1. [Switching to TypeScript And Module Loading](#switching-to-typescript-and-module-loading) 2. [Preparing Unit and E2E Tests](#preparing-unit-and-e2e-tests) 3. [Enjoying The Benefits of TypeScript](#enjoying-the-benefits-of-typescript) 4. [PhoneCat Upgrade Tutorial](#phonecat-upgrade-tutorial) 1. [Bootstrapping A Hybrid 1+2 PhoneCat](#bootstrapping-a-hybrid-1-2-phonecat) 2. [Upgrading the Phone factory](#upgrading-the-phone-factory) 3. [Upgrading Controllers to Components](#upgrading-controllers-to-components) 4. [Switching To The Angular 2 Router And Bootstrap](#switching-to-the-angular-2-router-and-bootstrap) 5. [Saying Goodbye to Angular 1](#saying-goodbye-to-angular-1) .l-main-section :marked # Preparation There are many ways to structure Angular 1 applications. When we begin to upgrade these applications to Angular 2, some will turn out to be much more easy to work with than others. There are a few key techniques and patterns that we can apply to future proof our apps even before we begin the migration. ## Following The Angular Style Guide The [Angular Style Guide](https://github.com/johnpapa/angular-styleguide) collects patterns and practices that have been proven to result in cleaner and more maintainable Angular 1 applications. It contains a wealth of information about how to write and organize Angular code - and equally importantly - how **not** to write and organize Angular code. Angular 2 is a reimagined version of the best parts of Angular 1. In that sense, its goals are the same as the Angular Style Guide's: To preserve the good parts of Angular 1, and to avoid the bad parts. There's a lot more to Angular 2 than just that of course, but this does mean that *following the style guide helps make your Angular 1 app more closely aligned with Angular 2*. There are a few rules in particular that will make it much easier to do *an incremental upgrade* using the Angular 2 `upgrade` module: * The [Rule of 1](https://github.com/johnpapa/angular-styleguide#single-responsibility) states that there should be one component per file. This not only makes components easy to navigate and find, but will also allow us to migrate them between languages and frameworks one at a time. In this example application, each controller, factory, and filter is in its own source file. * The [Folders-by-Feature Structure](https://github.com/johnpapa/angular-styleguide#style-y152) and [Modularity](https://github.com/johnpapa/angular-styleguide#modularity) rules define similar principles on a higher level of abstraction: Different parts of the application should reside in different directories and Angular modules. When an application is laid out feature per feature in this way, it can also be migrated one feature at a time. For applications that don't already look like this, applying the rules in the Angular style guide is a highly recommended preparation step. And this is not just for the sake of the upgrade - it is just solid advice in general! ## Using a Module Loader When we break application code down into one component per file, we often end up with a project structure with a large number of relatively small files. This is a much neater way to organize things than a small number of large files, but it doesn't work that well if you have to load all those files to the HTML page with `