不能够通过 @ngrx/component-store

问题描述 投票:0回答:1
import { ReservationStore } from 'src/app/Store/AddReservation.store'; @Component({ selector: 'app-new-booking-modal', templateUrl: './new-booking-modal.page.html', styleUrls: ['./new-booking-modal.page.scss'], providers: [ReservationStore], }) export class NewBookingModalPage implements OnInit { storagetestId$ = this.reservationStore.storagetestId$; constructor(private reservationStore: ReservationStore) {} ngOnInit() { this.bookingFun(' changed value'); } bookingFun(storagetestId) { this.reservationStore.patchState({ storagetestId }); } }
我试图通过调用商店在此处调用storagetestid的状态“ storagetestid”的价值,但要获得“ Storagetestid”的Intial值,我该如何更改状态值并在全球范围内更改状态值。我已经显示了我的商店文件和组件.ts下方
    
	
您的问题是将“提供商:[ReservationStore]”从每个组件移动到模块。

@NgModule({ imports: [BrowserModule, FormsModule], declarations: [ AppComponent, HelloComponent, NewBookingModalComponent, SecondViewComponent, ], bootstrap: [AppComponent], providers: [ReservationStore], }) export class AppModule {}

angular redux frontend store ngrx-store
1个回答
1
投票
https://stackblitz.com/edit/angular-ivy-bwvqpv?file = src/app/app/new-booking modal/new-booking-modal.component.ts


谢谢你!

最新问题
© www.soinside.com 2019 - 2025. All rights reserved.