Skip to content

Commit

Permalink
comments for todomvc example
Browse files Browse the repository at this point in the history
  • Loading branch information
Evan You committed Jan 21, 2014
1 parent c42e185 commit 78293a5
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions examples/todomvc/js/app.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
var app = new Vue({

// the root element that will be compiled
el: '#todoapp',

// a custom directive to wait for the DOM to be updated
// before focusing on the input field.
directives: {
'todo-focus': function (value) {
if (value) {
Expand All @@ -11,6 +14,8 @@ var app = new Vue({
}
},

// the `created` lifecycle hook.
// it will be called when the ViewModel instance is created.
created: function () {
this.filters = {
all: function (todo) { todo.completed; return true },
Expand All @@ -26,8 +31,13 @@ var app = new Vue({
}).length
},

// data
data: {

// fetch the saved todos from localStorage
todos: todoStorage.fetch(),

// a computed property with custom getter/setter
allDone: {
$get: function () {
return this.remaining === 0
Expand All @@ -42,6 +52,8 @@ var app = new Vue({
}
},

// methods that implement data logic.
// note there's no DOM manipulation here at all!
methods: {

updateFilter: function () {
Expand Down

0 comments on commit 78293a5

Please sign in to comment.