Skip to content

Instantly share code, notes, and snippets.

@Panman82
Last active May 12, 2016 19:58
Show Gist options
  • Save Panman82/4d42c5b59892bce7245d0de07b1fc00e to your computer and use it in GitHub Desktop.
Save Panman82/4d42c5b59892bce7245d0de07b1fc00e to your computer and use it in GitHub Desktop.
Cards List w/ Dismiss Action
import Ember from 'ember';
export default Ember.Controller.extend({
actions: {
removeCard( card ) {
let cards = this.get('model');
cards.removeObject( card );
}
}
});
import Ember from 'ember';
export default Ember.Route.extend({
model() {
return [{
title: "Card 1",
content: "This is the first card."
}, {
title: "Card 2",
content: "Foo bar baz quux"
}, {
title: "Card 3",
content: "Lorem ipsum dolar"
}];
}
});
<h3>Cards List w/ Dismiss Action</h3>
<h5>Number of cards: {{model.length}}</h5>
<br>
{{#each model as |card|}}
{{#mdl-card title=card.title}}
<div class="mdl-card__supporting-text">
{{card.content}}
</div>
{{#mdl-card-actions}}
{{mdl-button text='Dismiss' on-click=(action "removeCard" card)}}
{{/mdl-card-actions}}
{{/mdl-card}}
<br>
{{/each}}
{
"version": "0.8.0",
"EmberENV": {
"FEATURES": {}
},
"options": {
"use_pods": false,
"enable-testing": false
},
"addons": {
"ember-material-lite": "latest"
},
"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