How to get current value of State object with @ngrx/store?

后端 未结 10 1516
失恋的感觉
失恋的感觉 2020-12-08 06:13

My service class, before calling a web service, needs to get a property called dataForUpdate from my state. Currently, I\'m doing it like this:



        
10条回答
  •  情话喂你
    2020-12-08 06:46

    That's works for me. You need to import Store from '@ngrx/store' and AppState is your state.

    private state: AppState;
    
    constructor(private store: Store) { }
    
    ngOnInit() {
        this.store.select(x => this.state = x).subscribe();
    }
    

提交回复
热议问题