Browse Source

commit modif

placidenduwayo 2 years ago
parent
commit
eb67f85646

+ 1
- 1
src/app/pages/companies-manager/companies-management/companies-management.component.html View File

1
 <div class="container">
1
 <div class="container">
2
   <app-company-nav-bar></app-company-nav-bar>
2
   <app-company-nav-bar></app-company-nav-bar>
3
 
3
 
4
-  <ng-container *ngIf="companyState"  [ngSwitch]="companyState.msgState">
4
+  <ng-container *ngIf="companyState$ |async as companyState"  [ngSwitch]="companyState.msgState">
5
 
5
 
6
     <ng-container *ngSwitchCase="msgState.LOADING">
6
     <ng-container *ngSwitchCase="msgState.LOADING">
7
       {{companyState.msgState}}
7
       {{companyState.msgState}}

+ 6
- 5
src/app/pages/companies-manager/companies-management/companies-management.component.ts View File

1
+import { Observable } from 'rxjs';
1
 import { MsgState } from './../../../ngrx/msg.state';
2
 import { MsgState } from './../../../ngrx/msg.state';
2
 import { CompanyState } from './../../../ngrx/companies/company.state';
3
 import { CompanyState } from './../../../ngrx/companies/company.state';
3
 import { Component, OnInit } from '@angular/core';
4
 import { Component, OnInit } from '@angular/core';
4
-import { Store } from '@ngrx/store';
5
+import { select, Store } from '@ngrx/store';
5
 
6
 
6
 @Component({
7
 @Component({
7
   selector: 'app-companies-management',
8
   selector: 'app-companies-management',
12
 
13
 
13
   constructor(private store: Store<{companyReducerKey: CompanyState}>) { }
14
   constructor(private store: Store<{companyReducerKey: CompanyState}>) { }
14
 
15
 
15
-  companyState!: CompanyState;
16
+  companyState$!: Observable<CompanyState>;
16
   msgState = MsgState;
17
   msgState = MsgState;
17
 
18
 
18
   ngOnInit(): void {
19
   ngOnInit(): void {
19
 
20
 
20
-    this.store.subscribe( state =>{
21
-      this.companyState = state.companyReducerKey;
22
-    })
21
+    this.companyState$ = this.store.pipe(
22
+      select( state => state.companyReducerKey)
23
+    );
23
   }
24
   }
24
 
25
 
25
 }
26
 }

Powered by TurnKey Linux.