Skip to content

Instantly share code, notes, and snippets.

@LayZeeDK
Last active October 10, 2018 08:41
Show Gist options
  • Save LayZeeDK/a7ad6f5fc6cf9fade8400cd118f40880 to your computer and use it in GitHub Desktop.
Save LayZeeDK/a7ad6f5fc6cf9fade8400cd118f40880 to your computer and use it in GitHub Desktop.
Dashboard: Container component model
import { ChangeDetectionStrategy, Component } from '@angular/core';
import { Observable } from 'rxjs';
import { map } from 'rxjs/operators';
import { Hero } from '../hero';
import { HeroService } from '../hero.service';
@Component({
changeDetection: ChangeDetectionStrategy.OnPush,
selector: 'app-dashboard',
templateUrl: './dashboard.container.html',
})
export class DashboardContainerComponent {
topHeroes$: Observable<Hero[]> = this.heroService.getHeroes().pipe(
map(heroes => heroes.slice(1, 5)),
);
constructor(private heroService: HeroService) {}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment