Last active
April 7, 2016 01:18
-
-
Save kidGodzilla/220a2d39faf166da7cae3c73dbcb5c64 to your computer and use it in GitHub Desktop.
Tutorial
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({ | |
| filter: null, | |
| filteredList: null, | |
| actions: { | |
| autoComplete() { | |
| this.get('autoComplete')(this.get('filter')); | |
| }, | |
| search() { | |
| this.get('search')(this.get('filter')); | |
| }, | |
| choose(city) { | |
| this.set('filter', city); | |
| } | |
| } | |
| }); |
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({ | |
| isImageShowing: false, | |
| actions: { | |
| imageShow() { | |
| this.set('isImageShowing', true); | |
| }, | |
| imageHide() { | |
| this.set('isImageShowing', false); | |
| } | |
| } | |
| }); |
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', | |
| model: function () { | |
| return rentals; | |
| } | |
| }); |
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({ | |
| filteredList: null, | |
| listings: function () { | |
| return this.get('model'); | |
| }.property(), | |
| actions: { | |
| autoComplete(param) { | |
| if(param !== "") { | |
| var model = this.get('model'); | |
| model = model.filter(function (el) { | |
| return el.city.toLowerCase().indexOf(param.toLowerCase()) !== -1; | |
| }); | |
| this.set('filteredList', model); | |
| } else { | |
| this.set('filteredList').clear(); | |
| } | |
| }, | |
| search(param) { | |
| if(param !== "") { | |
| var listings = this.get('model'); | |
| listings = listings.filter(function (el) { | |
| return el.city.toLowerCase() === param.toLowerCase(); | |
| }); | |
| this.set('listings', listings); | |
| } else { | |
| this.set('listings', this.get('model')); | |
| } | |
| } | |
| } | |
| }); |
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
| export function initialize(application) { | |
| application.inject('route', 'mts', 'service:multivariate-testing-service'); | |
| application.inject('component', 'mts', 'service:multivariate-testing-service'); | |
| application.inject('controller', 'mts', 'service:multivariate-testing-service'); | |
| }; | |
| export default { | |
| name: 'multivariate-testing-service', | |
| initialize: initialize | |
| }; |
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'; | |
| var rentals = [{ | |
| id: 1, | |
| title: 'Grand Old Mansion', | |
| owner: 'Veruca Salt', | |
| city: 'San Francisco', | |
| type: 'Estate', | |
| bedrooms: 15, | |
| image: 'https://upload.wikimedia.org/wikipedia/commons/c/cb/Crane_estate_(5).jpg' | |
| }, { | |
| id: 2, | |
| title: 'Urban Living', | |
| owner: 'Mike TV', | |
| city: 'Seattle', | |
| type: 'Condo', | |
| bedrooms: 1, | |
| image: 'https://upload.wikimedia.org/wikipedia/commons/0/0e/Alfonso_13_Highrise_Tegucigalpa.jpg' | |
| }, { | |
| id: 3, | |
| title: 'Downtown Charm', | |
| owner: 'Violet Beauregarde', | |
| city: 'Portland', | |
| type: 'Apartment', | |
| bedrooms: 3, | |
| image: 'https://upload.wikimedia.org/wikipedia/commons/f/f7/Wheeldon_Apartment_Building_-_Portland_Oregon.jpg' | |
| }]; | |
| export default Ember.Route.extend({ | |
| model() { | |
| return rentals; | |
| } | |
| }); |
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.Service.extend({ | |
| testMe: function() { | |
| console.log("this is james!"); | |
| } | |
| }); |
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.7.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.4.3", | |
| "ember-data": "https://cdnjs.cloudflare.com/ajax/libs/ember-data.js/2.4.3/ember-data.js", | |
| "ember-template-compiler": "2.4.3" | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment