import { Component , OnInit } from '@angular/core' ; import { Store , select } from '@ngrx/store' ; import { ActivatedRoute } from '@angular/router' ; import { IAppState } from '../../store/state/app.state' ; import { selectSelectedUser } from '../../store/selectors/user.selector' ; import { GetUser } from '../../store/actions/user.actions' ; @ Component ( { templateUrl : './user.component.html' , styleUrls : [ './user.component.css' ] } ) export class UserComponent implements OnInit { user$ = this . _store . pipe ( select ( selectSelectedUser ) ) ; constructor ( private _store , private _route ) { } ngOnInit ( ) { this . _store . dispatch ( new GetUser ( this . _route . snapshot . params . id ) ) ; } }