I am trying to cast the content of my FormGroup value into an interface which I want use for posting something to my Web Api.
My interface looks like this:
export interface MoneyItemI {
  Description: string;
  Amount: number;
}
My submit methods looks like this:
onSubmit() {
    let jsonString = JSON.stringify(this.itemForm.value);
    let mi = <MoneyItemI>JSON.parse(jsonString);
}
I can see that I get an object created with JSON.parse but unfortunately it does not look like it an valid MoneyItemI object for me.
Property 'Amount' for example is not a number. It is assigned like a string.
How can I create a valid interface with the value of my FormGroup?
Does this.itemForm.value have the correct Amount and Description properties before you call JSON.stringify(this.itemForm.value)?
If so, you should be able to just do:
let mi = <MoneyItemI>this.itemForm.value;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With