Last active
January 5, 2018 09:47
-
-
Save kevinchisholm/24867592eb12c8cc49202daa1329907a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {Component} from '@angular/core'; | |
@Component({ | |
selector: 'home', | |
templateUrl: 'src/home/home.html', | |
styleUrls: ['src/home/home.css'] | |
}) | |
export class HomeComponent { | |
selectedDay: string = ''; | |
//event handler for the select element's change event | |
selectChangeHandler (event: any) { | |
//update the ui | |
this.selectedDay = event.target.value; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<article> | |
<h1>Angular Get Selected Option Value</h1> | |
<h2><span>Select a day:</span></h2> | |
<select (change)="selectChangeHandler($event)"> | |
<option value="Monday">Monday</option> | |
<option value="Tuesday">Tuesday</option> | |
<option value="Wednesday">Wednesday</option> | |
<option value="Thursday">Thursday</option> | |
<option value="Friday">Friday</option> | |
</select> | |
<p><span>You selected: </span><b>{{selectedDay}}</b></p> | |
</article> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment