Angular 2 does not have controllers anymore. Now is the time to turn our Angular 1 controllers into Angular 2 components.
- [Instructor] Hi, and welcome to Video 4.3,…where we are about to use Angular 2 Components…where we used to have Angular 1 Controllers in our code,…as controllers don't exist anymore in Angular 2.…We are specifically going to reorganize our code,…first, by moving most of our business logic…into a new WeatherService.…This will allow us to use dependency injection,…instead of events and call backs in our application.…Then we're going to create a new component…to replace our Forecast controller,…and a final one to replace our Main controller.…
Let's start by taking a look at…our main controller, main.ts.…It uses LocationsService to add and remove location,…yet we make an http request to get…the current weather conditions.…We also have to get weather icon method defined here,…which is used on both pages in our app,…so it would make more sense…to make it available in a more generic service.…On the other hand,…if we take a look at our LocationsService,…we can see that it really doesn't do much…besides storing locations for us.…
Angular 2 is a technical and conceptual overhaul of its hugely popular predecessor, AngularJS. To stay ahead, developers who have built and maintained projects with AngularJS need to be able to transition them to Angular 2. Migrating to Angular 2 demonstrates how to create and execute an effective migration plan for Angular applications. It opens with an introduction to the major changes and additions brought by the new framework. Then author Alain Chautard reviews a plan to migrate a sample weather application from its original Angular 1.x codebase.
Learn how to migrate blocks of code incrementally, as opposed to porting code in bulk, and get a brief introduction to TypeScript and ECMAScript 6. Along the way, Alain shows you how to gradually deprecate $scope, upgrade services, work with the component router, transition forms, and more.
By the end of this course, you'll be up to speed with the fundamental building blocks of Angular 2 development, and fully capable (and confident) transitioning existing Angular 1.x projects to the new environment, ready to explore everything that Angular 2 has to offer.
- What's new in Angular 2?
- Migrating incrementally
- What are TypeScript and ES6?
- Cleaning up $scopes
- Making components
- Using TypeScript classes
- Upgrading 1.x services, components, and controllers
- Best practices for Angular 2