I would like to create a model for reactive Form.
The JSON File look like this:
{
"ITEMS": [
{
"NAME": "aaa",
"QUANTITY": ["140", "60"]
}
]
}
Thanks for your help :)
I would like to create a model for reactive Form.
The JSON File look like this:
{
"ITEMS": [
{
"NAME": "aaa",
"QUANTITY": ["140", "60"]
}
]
}
Thanks for your help :)
Here have an example, item.model.ts and his application at app.component.ts.
https://stackblitz.com/edit/angular-s3obqy?embed=1&file=src/app/app.component.html
In your case with this stringified object you can parse like that at app.component.ts :
yourString = ` {
"ITEMS": [
{
"NAME": "aaa",
"QUANTITY": ["140", "60"]
}
]
}`;
foo: Item = JSON.parse(this.yourString);
export class DataModel { const ITEMS: [string, string[]]; const NAME: string; const QUANTITY: string[]; constructor() { this.ITEMS[{this.NAME, this.QUANTITY[]}]; } }