@filip.mam
@filip.mam
@filip.mam
@filip.mam
@filip.mam
@filip.mam
@filip.mam
@filip.mam
@filip.mam
@filip.mam
@filip.mam
<app-nav></app-nav>
<app-movies-ranking></app-movies-ranking>
<app-tv-shows-ranking></app-tv-shows-ranking>
<app-movie-finder></app-movie-finder>
<cw-button>Movies ranking</cw-buton>
<cw-button>TV shows ranking</cw-buton>
<cw-button>Movie finder</cw-buton>
@filip.mam
<app-nav></app-nav>
<app-movies-ranking *ngIf="activeIndex === 0"></app-movie-base>
<app-tv-shows-ranking *ngIf="activeIndex === 1"></app-actors-base>
<app-movie-finder *ngIf="activeIndex === 2"></app-movie-finder>
<cw-button (click)="activeIndex = 0">Movies ranking</cw-buton>
<cw-button (click)="activeIndex = 1">TV shows ranking</cw-buton>
<cw-button (click)="activeIndex = 2">Movie finder</cw-buton>
Chapter 1
@filip.mam
@filip.mam
<app-nav></app-nav>
<app-welcome-text *ngIf="activeIndex === undefined"></app-welcome-text>
<app-movies-ranking *ngIf="activeIndex === 0"></app-movies-ranking>
<app-tv-shows-ranking *ngIf="activeIndex === 1"></app-tv-shows-ranking>
<app-movie-finder *ngIf="activeIndex === 2"></app-movie-finder>
@filip.mam
<app-nav></app-nav>
<app-welcome-text *ngIf="activeIndex === undefined"></app-welcome-text>
<app-movies-ranking *ngIf="activeIndex === 0"></app-movies-ranking>
<app-tv-shows-ranking *ngIf="activeIndex === 1"></app-tv-shows-ranking>
<app-movie-finder *ngIf="activeIndex === 2"></app-movie-finder>
<app-box-office *ngIf="activeIndex === 3"></app-box-office>
<app-goodbay-text *ngIf="activeIndex === 4"></app-welcome-text>
<app-actors-base *ngIf="activeIndex === 5"></app-movie-base>
<app-tag-base *ngIf="activeIndex === 6"></app-actors-base>
<app-tag-finder *ngIf="activeIndex === 7"></app-movie-finder>
<app-show-office *ngIf="activeIndex === 8"></app-box-office>
@filip.mam
<app-nav></app-nav>
<app-welcome-text *ngIf="activeIndex === undefined"></app-welcome-text>
<app-movies-ranking *ngIf="activeIndex === 0"></app-movies-ranking>
<app-tv-shows-ranking *ngIf="activeIndex === 1"></app-tv-shows-ranking>
<app-movie-finder *ngIf="activeIndex === 2"></app-movie-finder>
<app-box-office *ngIf="activeIndex === 3"></app-box-office>
<app-goodbay-text *ngIf="activeIndex === 4"></app-welcome-text>
<app-actors-base *ngIf="activeIndex === 5"></app-movie-base>
<app-tag-base *ngIf="activeIndex === 6"></app-actors-base>
<app-tag-finder *ngIf="activeIndex === 7"></app-movie-finder>
<app-show-office *ngIf="activeIndex === 8"></app-box-office>
<app-welcome-text *ngIf="activeIndex === 9"></app-welcome-text>
<app-movie-base *ngIf="activeIndex === 10"></app-movie-base>
<app-actors-base *ngIf="activeIndex === 11"></app-actors-base>
<app-movie-finder *ngIf="activeIndex === 12"></app-movie-finder>
<app-box-office *ngIf="activeIndex === 33"></app-box-office>
<app-goodbay-text *ngIf="activeIndex === 14"></app-welcome-text>
<app-actors-base *ngIf="activeIndex === 15"></app-movie-base>
<app-tag-base *ngIf="activeIndex === 16"></app-actors-base>
<app-tag-finder *ngIf="activeIndex === 17"></app-movie-finder>
<app-show-office *ngIf="activeIndex === 18"></app-box-office>
<app-welcome-text *ngIf="activeIndex === 19"></app-welcome-text>
<app-movie-base *ngIf="activeIndex === 20"></app-movie-base>
@filip.mam
<app-nav></app-nav>
<app-welcome-text *ngIf="activeIndex === undefined"></app-welcome-text>
<app-movies-ranking *ngIf="activeIndex === 0"></app-movies-ranking>
<app-tv-shows-ranking *ngIf="activeIndex === 1"></app-tv-shows-ranking>
<app-movie-finder *ngIf="activeIndex === 2"></app-movie-finder>
<app-box-office *ngIf="activeIndex === 3"></app-box-office>
<app-goodbay-text *ngIf="activeIndex === 4"></app-welcome-text>
<app-actors-base *ngIf="activeIndex === 5"></app-movie-base>
<app-tag-base *ngIf="activeIndex === 6"></app-actors-base>
<app-tag-finder *ngIf="activeIndex === 7"></app-movie-finder>
<app-show-office *ngIf="activeIndex === 8"></app-box-office>
<app-welcome-text *ngIf="activeIndex === 9"></app-welcome-text>
<app-movie-base *ngIf="activeIndex === 10"></app-movie-base>
<app-actors-base *ngIf="activeIndex === 11"></app-actors-base>
<app-movie-finder *ngIf="activeIndex === 12"></app-movie-finder>
<app-box-office *ngIf="activeIndex === 33"></app-box-office>
<app-goodbay-text *ngIf="activeIndex === 14"></app-welcome-text>
<app-actors-base *ngIf="activeIndex === 15"></app-movie-base>
<app-tag-base *ngIf="activeIndex === 16"></app-actors-base>
<app-tag-finder *ngIf="activeIndex === 17"></app-movie-finder>
<app-show-office *ngIf="activeIndex === 18"></app-box-office>
<app-welcome-text *ngIf="activeIndex === 19"></app-welcome-text>
<app-movie-base *ngIf="activeIndex === 20"></app-movie-base>
<app-actors-base *ngIf="activeIndex === 21"></app-actors-base>
<app-movie-finder *ngIf="activeIndex === 22"></app-movie-finder>
<app-box-office *ngIf="activeIndex === 23"></app-box-office>
<app-goodbay-text *ngIf="activeIndex === 24"></app-welcome-text>
<app-actors-base *ngIf="activeIndex === 25"></app-movie-base>
<app-tag-base *ngIf="activeIndex === 26"></app-actors-base>
<app-tag-finder *ngIf="activeIndex === 27"></app-movie-finder>
<app-show-office *ngIf="activeIndex === 28"></app-box-office>
<app-welcome-text *ngIf="activeIndex === 29"></app-welcome-text>
<app-movie-base *ngIf="activeIndex === 30"></app-movie-base>
<app-actors-base *ngIf="activeIndex === 31"></app-actors-base>
<app-movie-finder *ngIf="activeIndex === 32"></app-movie-finder>
<app-box-office *ngIf="activeIndex === 33"></app-box-office>
@filip.mam
@filip.mam
Chapter 2
@filip.mam
@filip.mam
@filip.mam
const routes = [{
path: "movie-finder",
component: MovieFinderComponent
}]
const routes = [{
path: "movie-finder",
component: MovieFinderComponent
}]
@NgModule(
declarations: [MovieFinderComponent],
imports: [RouterModule.forRoot(routes)]
)
export class AppModule {}
@filip.mam
<header>Need something to watch?</header>
<app-nav></app-nav>
<app-welcome-text></app-welcome-text>
<app-movie-base></app-movie-base>
<app-actors-base></app-actors-base>
<app-movie-finder></app-movie-finder>
<app-box-office></app-box-office>
<header>Need something to watch?</header>
<app-nav></app-nav>
<header>Need something to watch?</header>
<app-nav></app-nav>
<router-outlet></router-outlet>
@filip.mam
const routes = [{
path: "movie-finder",
component: MovieFinderComponent
}]
const routes = [{
path: "movie-finder",
component: MovieFinderComponent
},
{
path: "tv-shows-base",
component: ActorsBaseComponent
},
{
path: "movies-base",
component: MoviesBaseComponent
}]
@filip.mam
<cw-button routerLink="movies-base">Movies base</cw-buton>
<cw-button routerLink="tv-shows-base">TV shows base</cw-buton>
<cw-button routerLink="movie-finder">Movie finder</cw-buton>
<cw-button (click)="goToMovieBase()">Movies base</cw-buton>
...
goToMovieBase(): void {
this.routerService.navigate('/movie-base');
}
<cw-button (click)="activeIndex = 0">Movies ranking</cw-buton>
<cw-button (click)="activeIndex = 1">TV shows ranking</cw-buton>
<cw-button (click)="activeIndex = 2">Movie finder</cw-buton>
@filip.mam
<header>Need something to watch?</header>
<app-nav></app-nav>
<app-welcome-text *ngIf="activeIndex === undefined"></app-welcome-text>
<app-movie-base *ngIf="activeIndex === 0"></app-movie-base>
<app-actors-base *ngIf="activeIndex === 1"></app-actors-base>
<app-movie-finder *ngIf="activeIndex === 2"></app-movie-finder>
<app-box-office *ngIf="activeIndex === 3"></app-box-office>
<header>Need something to watch?</header>
<app-nav></app-nav>
<router-outlet></router-outlet>
@filip.mam
@filip.mam
movies
ranking
tvShows
ranking
movie
finder
commons
vendors
@filip.mam
movie
ranking
tvShows
ranking
movie
finder
commons
vendors
@filip.mam
@filip.mam
Chapter 3
@filip.mam
commons
vendors
@filip.mam
shows ranking
commons
vendors
@filip.mam
shows
ranking
commons
vendors
movie
finder
@filip.mam
@filip.mam
@Component({
...
})
export class MovieFinderComponent {
...
}
@NgModule(
declarations: [MovieFinderComponent]
)
export class MovieFinderModule {}
@NgModule(
declarations: [MovieFinderComponent],
imports: [RouterModule.forChildren(movieFinderRoutes)]
)
export class MovieFinderModule {}
const movieFinderRoutes = [{
path: "",
component: MovieFinderComponent
}]
@filip.mam
const routes = [{
path: "movie-finder",
component: MovieFinderComponent
},
{
path: "tv-shows-base",
component: ActorsBaseComponent
},
{
path: "movies-base",
component: MoviesBaseComponent
}]
const routes = [{
path: "movie-finder",
loadChildren:
},
{
path: "tv-shows-base",
loadChildren:
},
{
path: "movies-base",
loadChildren:
}]
const routes = [{
path: "movie-finder",
loadChildren: "./modules/movie-finder.module/#MovieFinderModule"
},
{
path: "tv-shows-base",
loadChildren: "./modules/tv-shows-base.module/#TvShowsBaseModule"
},
{
path: "movies-base",
loadChildren: "./modules/movies-base.module/#MoviesBaseModule"
}]
@filip.mam
@filip.mam
movieList = [...]
...
<div *ngFor="let movie of movieList">
{{movie.title}} {{movie.year}}
</div>
@filip.mam
@Component({
...
})
class MoviesRankingComponent {
movieList: Movie[] = [
{title: "Godfather", year: "1972"},
{title: "Inception", year: "2010"},
...
]
}
with static data
@filip.mam
with async data
@Component({
...
})
class MoviesRankingComponent {
movieList: Movie[] = [];
constructor(http: Http) {
http.get('api/movies').subscribe(
movies => this.movieList = movies;
);
}
}
@filip.mam
1
2
3
lifecycle with async data
@filip.mam
2
3
@filip.mam
2
3
@filip.mam
Chapter 4
@filip.mam
/movies-ranking
/movie-finder
/tv-shows-ranking
@filip.mam
/movie-finder
@filip.mam
const moviesRankingRoutes = [{
path: "",
component: moviesRankingComponent,
resolver: {
movies: MoviesResolver
}
}]
@filip.mam
@Injectable()
class MoviesResolver implement Resolve<Movie[]> {
constructor(http: Http) {}
public resolve(): Observable<Movie[]> {
return this.http.get("api/movies");
}
}
@filip.mam
1
2
3
4
with resolver
@filip.mam
@Component({
...
})
class MovieFinderComponent {
movieList: Movie[] = [];
constructor(route: ActivatedRouteSnapshot) {
this.movieList = route.data.movies
}
}
@filip.mam
@filip.mam
Chapter 5
@filip.mam
public resolve(): Observable<Movie[]> {
return this.http.get("api/tv-shows");
}
...
const tvShowsRankingRoutes = [{
path: "",
component: moviesRankingComponent,
resolver: {
tvShows: TvShowsResolver
}
}]
...
constructor(route: ActivatedRouteSnapshot) {
this.tvShows = route.data.tvShows
}
@filip.mam
const movieFinderRoutes = [{
path: "",
component: moviesRankingComponent,
resolver: {
movies: MoviesResolver,
tvShows: TvShowsResolver
}
}]
...
constructor(route: ActivatedRouteSnapshot) {
this.movies = route.data.movies;
this.tvShows = route.data.tvShows;
}
@filip.mam
@filip.mam
@filip.mam
@filip.mam
Chapter 6
@filip.mam
@Component({
template: "<div>LOADING...</div>",
styleUrls: ["./stlyes.url"]
})
class LoaderComponent {
...
}
@filip.mam
<header>Need something to watch?</header>
<app-nav></app-nav>
<router-outlet></router-outlet>
<router-outlet name="loader"></router-outlet>
@filip.mam
routes = [
...,
{
path: "loader",
component: LoaderComponent,
outlet: "loader"
}
]
@filip.mam
constructor(router: Router) {}
...
this.router.events.subscribe(event) {
if (event instanceof ResolveStart) {
this.showLoader();
}
if (event (instanceof ResolveEnd) {
this.hideLoader();
}
}
@filip.mam
@filip.mam
@filip.mam
Chapter 7