Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/29.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular NGRX TypeError:操作必须具有类型属性_Angular_Typescript_Rxjs_Ngrx - Fatal编程技术网

Angular NGRX TypeError:操作必须具有类型属性

Angular NGRX TypeError:操作必须具有类型属性,angular,typescript,rxjs,ngrx,Angular,Typescript,Rxjs,Ngrx,我不明白如何避免这样的错误NGRX-TypeError:操作必须有一个type属性。请帮我找出哪里出了问题 我有两个动作, export class UpdateWordListAction implements Action { static readonly TYPE: 'UPDATE_WORD_LIST'; readonly type: "UPDATE_WORD_LIST"; constructor() {}; } export class Wo

我不明白如何避免这样的错误
NGRX-TypeError:操作必须有一个type属性
。请帮我找出哪里出了问题

我有两个动作,

export class UpdateWordListAction implements Action {
    static readonly TYPE: 'UPDATE_WORD_LIST';
    readonly type: "UPDATE_WORD_LIST";
    constructor() {};
}
export class WordListLoadedSuccessAction implements Action {
    readonly words: Word[];
    static readonly TYPE: 'WORD_LIST_LOADED_SUCCESS';
    readonly type: "WORD_LIST_LOADED_SUCCESS";
    constructor(words: Word[]) {};
}
@Injectable()
export class MyEffects {
 
     testEffect$ = createEffect(() => 
      this.actions$.pipe(
        ofType(UpdateWordListAction.TYPE),
        switchMap(() => this.wordService.getWordList()),
        map(words => new WordListLoadedSuccessAction(words)),
        catchError(() => EMPTY)));
 
  constructor(
    private actions$: Actions,
    private wordService: WordService
  ) {}
}
一种效果,

export class UpdateWordListAction implements Action {
    static readonly TYPE: 'UPDATE_WORD_LIST';
    readonly type: "UPDATE_WORD_LIST";
    constructor() {};
}
export class WordListLoadedSuccessAction implements Action {
    readonly words: Word[];
    static readonly TYPE: 'WORD_LIST_LOADED_SUCCESS';
    readonly type: "WORD_LIST_LOADED_SUCCESS";
    constructor(words: Word[]) {};
}
@Injectable()
export class MyEffects {
 
     testEffect$ = createEffect(() => 
      this.actions$.pipe(
        ofType(UpdateWordListAction.TYPE),
        switchMap(() => this.wordService.getWordList()),
        map(words => new WordListLoadedSuccessAction(words)),
        catchError(() => EMPTY)));
 
  constructor(
    private actions$: Actions,
    private wordService: WordService
  ) {}
}
以及此类客户

this.store.dispatch(new UpdateWordListAction());

您需要使用赋值符号而不是冒号。试试这个:

    export class UpdateWordListAction implements Action {
       readonly type = "UPDATE_WORD_LIST";
       constructor() {};
    }