Reputation: 189
Below is my .html code.
<select class="form-control" id="location" required [(ngModel)]="locations" name="location" #location="ngModel">
<option *ngFor="let location of locationType.locations" [value]="location.city_id" >{{location.city_name}}</option>
</select>
<button (click)='getFilterDetails(locations)'>Search</button>
and below is my .ts file code getting data from select box when click button
getFilterDetails(data){
console.log(data); }
Any body help how to get value of select box when click button?
Upvotes: 2
Views: 2306
Reputation: 222720
You can directly get the value since you are using ngModel,
getFilterDetails(){
console.log(this.locations);
}
Upvotes: 1