Advertisement
Guest User

Untitled

a guest
Apr 20th, 2019
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. // counter.component.ts
  2.  
  3. import { Component, OnInit, Injector } from '@angular/core';
  4. import { Store, select } from '@ngrx/store';
  5. import { Observable } from 'rxjs';
  6.  
  7.  
  8. @Component({
  9. selector: 'app-counter',
  10. templateUrl: './counter.component.html',
  11. styleUrls: ['./counter.component.css']
  12. })
  13. export class CounterComponent implements OnInit {
  14.  
  15. count$: Observable<number>;
  16.  
  17. constructor(private store: Store<{ count: number }>) {
  18.  
  19. }
  20.  
  21. ngOnInit() {
  22. this.count$ = this.store.pipe(select('count'));
  23. }
  24. }
  25.  
  26.  
  27. //counter.component.html
  28.  
  29. <div>Current Count: {{ count$ | async }}</div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement