Last active
February 12, 2018 20:57
-
-
Save pixelhandler/b0021e9c47f2770f05287096d1cbcf9a to your computer and use it in GitHub Desktop.
New Twiddle
This file contains hidden or 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 Ember from 'ember'; | |
| export default Ember.Component.extend({ | |
| zipCode: '', | |
| actions: { | |
| lookup() { | |
| let action = this.get('lookupAction'); | |
| let zipCode = this.element.querySelector('input').value; | |
| return action(zipCode); | |
| } | |
| } | |
| }); |
This file contains hidden or 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 Ember from 'ember'; | |
| export default Ember.Controller.extend({ | |
| appName: 'Ember Twiddle' | |
| }); |
This file contains hidden or 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 Ember from 'ember'; | |
| export default Ember.Controller.extend({ | |
| restaurants: Ember.inject.service(), | |
| lookupRestaurants(zipCode) { | |
| this.get('restaurants').findByZip(zipCode).then(function(sortedByZip) { | |
| console.log('results', sortedByZip); | |
| this.set('results', sortedByZip); | |
| }.bind(this)); | |
| } | |
| }); |
This file contains hidden or 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 Ember from 'ember'; | |
| export default Ember.Route.extend({ | |
| }); |
This file contains hidden or 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 Ember from 'ember'; | |
| import RSVP from 'rsvp'; | |
| export default Ember.Service.extend({ | |
| findByZip(zipCode) { | |
| let url = 'https://ordering--greg3-oloqa-com-fkt3fatgepjd.runscope.net/v1.1/restaurants/near?zip=' +zipCode+'&radius=25&limit=25&key=whSXSTrML2xHgtGhbzQ2tjsRfGxcJksX'; | |
| return new RSVP.Promise(function(resolve, reject) { | |
| let req = window.fetch(url).then((response) => { | |
| response.json().then(function(data) { | |
| let sorted = data.restaurants.sortBy('distance'); | |
| resolve(sorted); | |
| }); | |
| }); | |
| }); | |
| } | |
| }); |
This file contains hidden or 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
| { | |
| "version": "0.13.0", | |
| "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.16.2", | |
| "ember-template-compiler": "2.16.2", | |
| "ember-testing": "2.16.2" | |
| }, | |
| "addons": { | |
| "ember-data": "2.16.3" | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment