Created
June 27, 2020 20:41
-
-
Save kingsley-einstein/455c319191027bddabe8f3d6fd429357 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="flexed" *ngIf="user$ | async as user"> | |
<div class="inner-flexed"> | |
<ul> | |
<li>Name: {{user.firstName}} {{user.lastName}}</li> | |
<li>Email: {{user.email}}</li> | |
<li>D.O.B: {{user.dob}}</li> | |
</ul> | |
</div> | |
</div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Component, OnInit } from '@angular/core'; | |
import { ActivatedRoute } from '@angular/router'; | |
import { Store, select } from '@ngrx/store'; | |
import { AppState } from '../../management/states'; | |
import { LoadUserActionPing } from '../../management/actions'; | |
import { selectUser } from '../../management/selectors'; | |
@Component({ | |
selector: 'app-view-user', | |
templateUrl: './view-user.component.html', | |
styleUrls: ['./view-user.component.css'] | |
}) | |
export class ViewUserComponent implements OnInit { | |
email$: string = ''; | |
constructor(private store: Store<AppState>, private route: ActivatedRoute) { | |
route.params.subscribe((params) => { | |
this.email$ = params.email; | |
}); | |
} | |
user$ = this.store.pipe(select(selectUser)); | |
ngOnInit() { | |
console.log('[ViewUserComponent] initialised'); | |
this.store.dispatch(new LoadUserActionPing(this.email$)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment