A big goal the Angular team had was to achieve automatic lazy loading. This ensures our applications only load what is necessary for the current page. Lazy loading is also included when routing our applications.
import { Component, OnInit } from '@angular/core';
import { Hero } from './hero';
import { HeroDetailComponent } from './hero-detail.component';
import { HeroService } from './hero.service';
@Component({
moduleId: module.id,
selector: 'my-app',
template: ...
Angular 1 |
Angular 2 |
43 Directives | [] and () |
@Component({
moduleId: module.id,
selector: 'quest-summary',
templateUrl: 'quest-summary.component.html',
styleUrls: ['quest-summary.component.css']
})
export class QuestSummaryComponent { }
<div *ngIf="hero">
<h2>{{hero.name}} details!</h2>
<div><label>id: </label>{{hero.id}}</div>
<div>
<label>name: </label>
<input [(ngModel)]="hero.name" placeholder="name"/>
</div>
</div>
(hero.service.ts)
import { Injectable } from '@angular/core';
@Injectable()
export class HeroService {
getHeroes() {
return Promise.resolve(HEROES);
}
}
(app.component.ts)
import { Component, OnInit } from '@angular/core';
import { Hero } from './hero';
import { HeroDetailComponent } from './hero-detail.component';
import { HeroService } from './hero.service';
@Component({
selector: 'my-app',
template: ...
directives: [HeroDetailComponent],
providers: [HeroService]
})
export class AppComponent implements OnInit {
title = 'Tour of Heroes';
heroes: Hero[];
selectedHero: Hero;
constructor(private heroService: HeroService) { }
ngOnInit() {
this.heroes = this.heroService.getHeroes();
}
}
name: string;
age: number;
isEnabled: boolean;
pets: string[];
accessories: string | string[];
customer: ICustomer;
@Component({
selector: 'my-app',
template:`
<h1>{{title}}</h1>
<h2>{{hero.name}} details!</h2>
`
})
ng new heroes-app
npm install -g angular-cli
ng new heroes-app
cd heroes-app
ng serve
ng build
ng test
ng e2e
ng serve
ng deploy
Angular Material for Angular 2 is looking really good. Building out beautiful material styled applications is very easy with these material components.
Service Worker is a relatively new addition to the Web Platform, and is a critical component to building true Progressive Web Apps. Not only does Service Worker make it possible to make apps load without an internet connection, it also makes it possible to push notifications and updates to a user's device while the app isn't even running
The style guide is living document.
The guide tells you what to do, consider, and avoid. And most importantly, why?
What are my options?
There are some things we can today to make upgrading our application easier:
.service()
instead of .factory()