Is there a way where I can access the selected item in drop down list in ember via controller? Give me a short example.
Thanks in advance!
You can create a drop down list by using HTML <select>
:
Controller:
import Ember from 'ember';
export default Ember.Controller.extend({
options: ['red', 'green', 'blue'],
selectedColor: null
});
Template:
Pick your favourite color:
<br/>
<select onchange={{action (mut selectedColor) value='target.value'}}>
{{#each options as |option|}}
<option value={{option}}>{{option}}</option>
{{/each}}
</select>
<br/><br/>
Your favourite color is: <b>{{selectedColor}}</b>
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.