Pass Template Input Values to Reducers

John Lindquist
InstructorJohn Lindquist

Share this video with your friends

Send Tweet

Angular allows you to pass values from inputs simply by referencing them in the template and passing them into your Subject.next() call. This lesson shows you how to make a number input and pass the value so you can configure how much you want the clock to change.

Nathan Brenner
Nathan Brenner
~ 5 years ago
    click$ = new Subject()
        .map((value)=> ({type: HOUR, payload: parseInt(value)}));

The typescript compiler doesn't like that. It says "Argument of type '{}' is not assignable to parameter of type 'string'." But it works in the browser as expected.

If I take out the parseInt function, typescript is happy, but it changes the day by 4 values (from say Oct 9 to Oct 13), even though the input.value is 0.

Any idea what needs to be changed to make the ts compiler happy and the browser to work as expected?

Sudhakar
Sudhakar
~ 4 years ago
click$ = new Subject<string>().map((value) => ({type:HOUR, payload:parseInt(value)}));