2017-08-31 15 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) => {