2017-08-31 31 views
0
ERROR in Error encountered resolving symbol values statically. Function calls are not supported. Consider replacing the function or lambda with a reference to an exported function (position 8:51 in the original .ts file), resolving symbol LocationStore in /root/ngrxbasedproject/src/app/reducer/reducer.ts, resolving symbol AppModule in /root/ngrxbasedproject/src/app/app.module.ts, resolving symbol AppModule in /root/ngrxbasedproject/src/app/app.module.ts, resolving symbol AppModule in /root/ngrxbasedproject/src/app/app.module.ts 

我不會爲什麼會發生這種情況。創建減速器時出錯

我app.module.ts是

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 { } 

我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

這是你使用的ngrx版本 –

回答

0

您需要將減速導出爲一個功能

而不是

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

使用

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