Complete the code to import the NgRx StoreModule in an Angular standalone component.
import { StoreModule } from '@ngrx/store'; @Component({ standalone: true, imports: [StoreModule.[1]({})], selector: 'app-root', template: `<h1>Welcome</h1>` }) export class AppComponent {}
The StoreModule.forRoot method sets up the root store in an Angular app.
Complete the code to select a piece of state from the store using a selector.
this.userName$ = this.store.select([1]);Selectors are functions that extract slices of state. The common naming is selectUserName.
Fix the error in dispatching an action to the store.
this.store.[1](loadItems());The correct method to send actions to the store is dispatch.
Fill both blanks to define a reducer function with initial state and action handling.
export const counterReducer = createReducer( [1], on(increment, state => ({ count: state.count [2] 1 })) );
The initial state is an object with count 0, and the increment adds 1 to count.
Fill all three blanks to create a feature store module with a reducer and selector.
StoreModule.[1]('counter', [2]), export const selectCounter = createFeatureSelector<CounterState>('[3]');
forFeature registers a feature store slice named 'counter' with its reducer. The selector uses the same feature name.