1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

Ngrx props<>() method in createAction()

Discussão em 'Angular' iniciado por Jagrit Goyal, Junho 19, 2025.

  1. Jagrit Goyal

    Jagrit Goyal Guest

    I wanted to ask if we can give any default value in the props<>() just like we give a default value in function arguments

    export const set = createAction(
    '[Counter] Set',
    props<{ value: number }>()
    );


    Here I want to give a default number to the "value" property in props<{ value: number }>().

    Is there any way of doing so?

    I tried adding the number similar to what we do in function arguments:

    export const set = createAction(
    '[Counter] Set',
    props<{ value = 0 }>()
    );


    But it resulted in error!:

    Operator '<' cannot be applied to types '<P extends SafeProps, SafeProps = NotAllowedInPropsCheck<P>>() => ActionCreatorProps<P>' and '{ value: number; }'

    Continue reading...

Compartilhe esta Página