Skip to content

Instantly share code, notes, and snippets.

@kingsley-einstein
Created June 27, 2020 20:41
Show Gist options
  • Save kingsley-einstein/455c319191027bddabe8f3d6fd429357 to your computer and use it in GitHub Desktop.
Save kingsley-einstein/455c319191027bddabe8f3d6fd429357 to your computer and use it in GitHub Desktop.
<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>
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