Skip to content

Instantly share code, notes, and snippets.

@sivakumar-kailasam
Last active November 8, 2017 12:24
Show Gist options
  • Save sivakumar-kailasam/9127a5434331f08578ee210e36253246 to your computer and use it in GitHub Desktop.
Save sivakumar-kailasam/9127a5434331f08578ee210e36253246 to your computer and use it in GitHub Desktop.
New Twiddle
import Ember from 'ember';
export default Ember.Component.extend({
});
import Ember from 'ember';
export default Ember.Component.extend({
});
import Ember from 'ember';
import config from './config/environment';
const Router = Ember.Router.extend({
location: 'none',
rootURL: config.rootURL
});
Router.map(function() {
this.route('active');
this.route('completed');
});
export default Router;
import Ember from 'ember';
export default Ember.Route.extend({
todoService: Ember.inject.service('todo'),
model() {
return this.get('todoService').get('activeTasks');
}
});
import Ember from 'ember';
export default Ember.Route.extend({
todoService: Ember.inject.service('todo'),
model() {
return this.get('todoService').get('completedTasks');
}
});
import Ember from 'ember';
export default Ember.Route.extend( {
todoService: Ember.inject.service('todo'),
model() {
return this.get('todoService').get('tasks');
}
});
import Ember from 'ember';
export default Ember.Service.extend({
completedTasks: Ember.computed.filterBy('tasks', 'isCompleted', true),
activeTasks: Ember.computed.filterBy('tasks', 'isCompleted', false),
tasks: [{
name: 'First',
isCompleted: false
},{
name: 'Second',
isCompleted: false
},{
name: 'Third',
isCompleted: false
},{
name: 'Fourth',
isCompleted: true
},{
name: 'Fifth',
isCompleted: true
}]
});
body {
margin: 12px 16px;
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
font-size: 12pt;
}
ul {
list-style:none;
}
{{todo-list tasks=model}}
<h1>todos</h1>
{{input placeholder="What needs to be done?"}}
<section>
{{outlet}}
</section>
<section>
{{#link-to 'index'}}All{{/link-to}}
{{#link-to 'active'}}Active{{/link-to}}
{{#link-to 'completed'}}Completed{{/link-to}}
<button>Clear all completed</button>
</section>
{{todo-list tasks=model}}
<input type="checkbox" id="first" checked={{task.isCompleted}}><label for="first">{{task.name}}</label> <button>clear item</button>
<ul>
{{#each tasks as |task|}}
{{todo-item task=task}}
{{/each}}
</ul>
<span> 2 items left</span>
{{todo-list tasks=model}}
{
"version": "0.12.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.12.0",
"ember-template-compiler": "2.12.0",
"ember-testing": "2.12.0"
},
"addons": {
"ember-data": "2.12.1"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment