Angular 2 is now in release candidate and can be used for new projects, though Angular 1 will still be supported for the next 1.5-2 years. There are two main approaches to upgrading an existing Angular 1 app to Angular 2: big bang, where the entire app is rewritten at once in Angular 2, or incremental, where individual components are upgraded one by one. Components and directives are now unified under the component model in Angular 2. TypeScript is recommended for Angular 2 development but not required, as JavaScript can also be used.
2. LAURENT DUVEAU
@LaurentDuveau
Founder of the Angular Academy
2-day Angular Classroom Training
23 classes in the last 10 months
Montreal, Quebec, Toronto, Vancouver,
Ottawa, Calgary, …
19. ANGULAR 2 COMPONENT
Angular 1.x: Directives and Controllers were two different things
Angular 2: Directives and Controllers unified into the Component model
7/9/2016 19
@Component({
selector:'tab-container'
})
class TabContainer {
...
constructor(todos:Array<Todo>) {
this.todos = todos;
}
deleteTodo(selectedTodo:Todo) { ... }
}
20. NG1 VS NG2
ng1 has 46 directives
ng2 has () and []
7/9/2016 20
25. PREPARING THE UPGRADE
Things you can do today to make your life easier:
Follow the Angular Style Guide!
Use .service() instead of .factory()
Remove dependencies on $scope
•Use controller as and this
Use the new component syntax (ng 1.5)
Adopt TypeScript!
ADOPT TYPESCRIPT!!
25
26. UPGRADE STRATEGIES
2 options:
Big Bang: Start a spike in Angular 2 and replace entire
app once done
Incremental: Upgrade existing app one service or
component at a time
26