My JSON data is structured like this:
Whenever I choose an option, I want to pass the values (code and description) from the JSON object to the component.
nameList= [
{
"code": "1",
"description": "abc"
},
{
"code": "123",
"description": "def"
},
{
"code": "100",
"description": "ijk"
}
]
Below is the HTML code:
<select [(ngModel)]="description" #category="ngModel" aria-required
(change)="getNameList()"> //want to send data.code value to component
<option style="display:none"></option>
<option *ngFor="let data of nameList"> {{data.description}}
</option>
</select>