Reactive form, if user-input from keyboard is 1000000
expects to see 10,000.00
. So a pipe is needed. Found a few SO posts,
- not working, use .valueChanges,
.valueChanges
is underlined with curly braces, implemented in code below, error. - not working, use .value,
.value
is underlined with curly braces error too.[value]="fg.get('fcTest').value | number: '9.2-2'"
- complicated, subscription to patch the value in this video.
Seems like have to add some code to subscribe
for value change event, no simple way?
<form [formGroup]="fg">
<input
type="number"
class="fc"
placeholder="integer"
formControlName="fcTest"
id="fcTest"
[value]="fg.get('fcTest').valueChanges |async | number: '9.2.2'"
/>
</form>
fg: FormGroup;
constructor(private fb: FormBuilder) {
this.fg = this.fb.group({
fcTest: ['', [Validators.required]]
});
}