Skip to content

Instantly share code, notes, and snippets.

@hell03610
Last active November 10, 2017 22:29
Show Gist options
  • Save hell03610/5665f29037e72aac53e04b554737e44b to your computer and use it in GitHub Desktop.
Save hell03610/5665f29037e72aac53e04b554737e44b to your computer and use it in GitHub Desktop.
31 - DDAU
import Ember from 'ember';
export default Ember.Component.extend({
home: null,
actions: {
click: function() {
this.get('onFav')(this.get('home'));
}
}
});
import Ember from 'ember';
export default Ember.Controller.extend({
actions: {
save: function(home) {
console.log('xxx', home);
}
}
});
import Ember from 'ember';
export default Ember.Route.extend({
model: function() {
return [
Ember.Object.create({
title: 'Seafront family home in pristine nature',
country: 'Iceland',
photo: 'https://dax87tnsniies.cloudfront.net/images/listing/large-56dpopgpm.jpg',
lastModified: new Date()
}),
Ember.Object.create({
title: 'Enjoy in a quiet natural area surrounded by sea and delicious food',
country: 'Spain',
photo: 'https://d11xw4p8b78xz0.cloudfront.net/images/p/1/a/5/2/600_396_dyn_p1a52au3a81c7n1o0b1fem16g51g2vg.jpg?m=1453766586',
lastModified: new Date()
})
]
}
});
<h1>Homes</h1>
{{#each model as |home|}}
{{home-profile home=home onFav=(action "save")}}
{{/each}}
<h2>{{home.title}}</h2>
<p>Location: {{home.country}}</p>
<p>Last modified: {{home.lastModified}}</p>
<button {{action "click"}}>Save as favorite</button><br>
{
"version": "0.8.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.5.1",
"ember-data": "2.5.2",
"ember-template-compiler": "2.5.1"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment