2017-08-31 3 views
0

Ich weiß nicht, warum es happing ist.Fehler beim Erstellen von Reducer

mein app.module.ts ist

import { BrowserModule } from '@angular/platform-browser'; 
import { NgModule } from '@angular/core'; 
import { AppComponent } from './app.component'; 
import { LocationStore } from './reducer/reducer'; 
import { Store, StoreModule } from "@ngrx/store"; 


@NgModule({ 
    declarations: [ 
    AppComponent 
    ], 

    imports: [ 
    BrowserModule, 
    StoreModule.provideStore({LocationStore}), 
], 

providers: [], 
bootstrap: [AppComponent] 
})Ï 

export class AppModule { } 

mein reduce.ts

import {Action , ActionReducer} from '@ngrx/store'; 

const initialState: any = { 
    selectedLocation : '', 
    allLocations : [] 
}; 
export const LocationStore : ActionReducer<any> = 
    (state = initialState , action : Action) => { 
     switch(action.type){ 
      case 'LOCATION_UPDATED': 
       action.payload = {city : 'chandigarh'} 
       console.log(action.payload); 
       console.log(state); 
       return Object.assign({}, state, action.payload); 
      case 'LOCATION_REC': 
       console.log(state); 
       return 'dfdgddf'; 
       // Final Data {city : 'chandigarh' ,state : 'chandi'} 
       // Final Data 
     } 
    } 
+0

das ist die Version von ngrx verwenden Sie –

Antwort

0

Sie brauchen, ist Ihr Minderer als Funktion

Statt

export const LocationStore : ActionReducer<any> = 
    (state = initialState , action : Action) => { 
exportieren

Verwenden Sie

export function LocationStore : ActionReducer<any> = 
    (state = initialState , action : Action) => {