Angular的ngOnInit中未触发reducer

时间:2019-12-10 13:18:57

标签: angular ngrx-store

ngOnInit() {

  //Storing a new object in store

  this.orderPayment = this.paymentStoreService.createOrderPayment( this.fund);
  this.orderPayment.amount = parseFloat( "1" );
  this.paymentStoreService.addPayment( this.orderPayment );

   //trying to get it back but getting null, because reducer does not call till yet  
  this.getPaymentSubscription = this.paymentStoreService.getPayment().subscribe( ( payment ) => {
    var x=payment;
  });
}

function button-click() {

  //Although, I am able to find the new added value from store over here on some button click event 
  //because till component load it fire the reducer  

}

0 个答案:

没有答案