Last active
February 1, 2016 00:34
-
-
Save camskene/77445468b76734f72457 to your computer and use it in GitHub Desktop.
Closure Actions
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:'Closure Actions', | |
| value: '', | |
| buttonText: 'click me', | |
| todos: [], | |
| posts: [], | |
| number: '', | |
| actions: { | |
| doSomething(e) { | |
| this.set('selectedSong', e); | |
| }, | |
| doSomethingElse(e) { | |
| console.log(e); | |
| }, | |
| addTodo() { | |
| this.get('todos').pushObject(this.get('todo')); | |
| this.set('todo', ''); | |
| }, | |
| removeTodo(todo) { | |
| this.get('todos').removeObject(todo); | |
| }, | |
| addPost(post) { | |
| this.get('posts').pushObject({title: this.get('title'), body: this.get('body')}); | |
| }, | |
| calculate() { | |
| const num = parseInt(this.get('number')); | |
| console.log(num); | |
| if (!isNaN(num)) { | |
| this.set('timesTwo', num *2 ); | |
| } else { | |
| this.set('timesTwo', 'Enter a valid number') | |
| } | |
| this.set('number', ''); | |
| } | |
| } | |
| }); |
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({ | |
| model() { | |
| return ['The Four Horsemen', 'Ride the Lightning', 'Master of Puppets'] | |
| } | |
| }); |
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({ | |
| text: 'click me', | |
| actions: { | |
| set() { | |
| this.get('on-click')(); | |
| } | |
| } | |
| }); |
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.5.0", | |
| "EmberENV": { | |
| "FEATURES": {} | |
| }, | |
| "options": { | |
| "enable-testing": false | |
| }, | |
| "dependencies": { | |
| "jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.0/jquery.js", | |
| "ember": "release", | |
| "ember-data": "release", | |
| "ember-template-compiler": "release" | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment