I am new to angular and my internship demands dealing with a lot of json texts and files. The json i'm currently working on looks like this (it represents a class) :
{
"name": "client",
"properties": {
"firstName": "string",
"lastName": "string",
"cin": "string",
"age": "int"
}
}
the angular project reads the json text from a textarea therefore the name and the properties can change.
I need to extract the name of the class and its attributes separetly each time i hit the submit button .
<form #json="ngForm" >
<textarea placeholder="paste your json file in here" rows="15" cols="150"></textarea>
<button (click)='sendJson(json)'> submit </button>
</form>
Can anyone help me please ?
Hey I'm not entirely sure what your asking but you can simply use and [(ngModel)]
to track the changes made and save it to a variable.
.TS
jsonChanges: string;
HTML
<textarea [(ngModel)]="jsonChanges" placeholder="paste your json file in here" rows="15" cols="150"></textarea>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.