Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // counter.component.ts
- import { Component, OnInit, Injector } from '@angular/core';
- import { Store, select } from '@ngrx/store';
- import { Observable } from 'rxjs';
- @Component({
- selector: 'app-counter',
- templateUrl: './counter.component.html',
- styleUrls: ['./counter.component.css']
- })
- export class CounterComponent implements OnInit {
- count$: Observable<number>;
- constructor(private store: Store<{ count: number }>) {
- }
- ngOnInit() {
- this.count$ = this.store.pipe(select('count'));
- }
- }
- //counter.component.html
- <div>Current Count: {{ count$ | async }}</div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement