Skip to content

Instantly share code, notes, and snippets.

@feanor07
Created March 20, 2017 11:53
Show Gist options
  • Save feanor07/a792a9366547a6780b65e54592247423 to your computer and use it in GitHub Desktop.
Save feanor07/a792a9366547a6780b65e54592247423 to your computer and use it in GitHub Desktop.
stackoverflow question #42833778
import Ember from 'ember';
var data = {
"pizzas": [{
"id": 1,
"name": "pizza 1"
}, {
"id": 2,
"name": "pizza 2"
}]
};
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
actions: {
queryPizzas(query, deferred) {
console.log(query.term);
new Ember.RSVP.Promise(function (resolve) {
setTimeout(function () {
console.log(data);
resolve(data);
}, 300)
}).then(function(data) {
//try to pass the array as the data
deferred.resolve({data: data.pizzas, more: false});
}, deferred.reject);
}
}
});
<h1>Welcome to {{appName}}</h1>
<br>
<br>
{{outlet}}
{{select-2
optionLabelPath="name"
placeholder="Choose from our many pizzas"
value=chosenTypeaheadPizza
typeaheadSearchingText="Searching pizzas"
typeaheadNoMatchesText="No pizzas found for '%@'"
typeaheadErrorText="Loading failed: %@"
query="queryPizzas"
}}
<br>
<br>
{
"version": "0.11.1",
"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.11.0",
"ember-data": "2.11.0",
"ember-template-compiler": "2.11.0",
"ember-testing": "2.11.0"
},
"addons": {
"ember-select-2": "1.3.0"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment