I want to get the selected text in Angular when I select an item in Dropdownlist.
Please Note that I want to get the text without any onchange
event in Dropdownlist. I use query selector to get the value of Dropdownlist and event is button and button inside form tag. Here is my code
const ddldepartment = target.querySelector('#ddldepartment').value;
const ddldesignation = target.querySelector('#ddldesignation').value;
Here I get the value like 1 and 2 not getting the text. and I am using
<form (submit)="PostEmployee($event)">
and
PostEmployee(event) {
const ddldepartment = target.querySelector('#ddldepartment').value;
const ddldesignation = target.querySelector('#ddldesignation').value;
}
Here is my HTML Code for the dropdownlist:
<select id="ddldepartment" [(ngModel)]="ddldepartment" name='ddlbankcode' style="width: 70%">
<option value=0>Choose...</option>
<option class='option' *ngFor="let dept of department" [value]="dept.dept_code">
{{dept.dept_name}}
</option>
</select>
I got value in console. I want to get text. How can I find it?