Skip to content

Instantly share code, notes, and snippets.

@kumkanillam
Created August 6, 2016 13:20
Show Gist options
  • Save kumkanillam/f0e54b5486e1279f6c08f46c716a833a to your computer and use it in GitHub Desktop.
Save kumkanillam/f0e54b5486e1279f6c08f46c716a833a to your computer and use it in GitHub Desktop.
Dropdwon-default selected
import Ember from 'ember';
export default Ember.Controller.extend({
lang: 'phpurl',
actions: {
selectOption: function(option) {
console.log(option);
this.set("lang", option);
}
}
});
import Ember from 'ember';
export default Ember.Route.extend({
model(){
return [{'url':'phpurl','title':'phptitle'},{'url':'javascripturl','title':'javascripttitle'}];
}
});
<select name="lang" id="lang" onchange={{action "selectOption" value="target.value"}}>
<option value="">--Choose--</option>
{{#each model as |item|}}
<option value="{{item.url}}" selected={{eq item.url lang}}>{{item.title}}</option>
{{/each}}
</select>
{{outlet}}
{
"version": "0.10.4",
"EmberENV": {
"FEATURES": {}
},
"options": {
"use_pods": false,
"enable-testing": false
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js",
"ember": "2.6.2",
"ember-data": "2.6.2",
"ember-template-compiler": "2.6.2"
},
"addons": {
"ember-truth-helpers": "1.2.0"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment