The ability to reply to discussions is limited to PRO members. Want to join in the discussion? Click here to subscribe now.

Passing Template Input Values to Reducers

Passing Template Input Values to Reducers

2:37
Angular 2 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.
Watch this lesson now
Avatar
egghead.io

Angular 2 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.

Avatar
Nathan Brenner
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?

Avatar
Sudhakar
click$ = new Subject<string>().map((value) => ({type:HOUR, payload:parseInt(value)}));
In reply to Nathan Brenner
HEY, QUICK QUESTION!
Joel's Head
Why are we asking?