Created
June 19, 2017 22:20
-
-
Save InTheCloudDan/623b4637a3ca8313dd5894e8ac5245cd to your computer and use it in GitHub Desktop.
This file contains 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
Vue.component('tasks', { | |
template: '#tasks-template', | |
created: function () { | |
this.fetchTaskList() | |
}, | |
methods: { | |
fetchTaskList: function() { | |
this.$http.get('api/tasks'), function(tasks) { | |
this.list = tasks; | |
}; | |
}, | |
toggleCompletedFor: function(task) { | |
task.completed = ! task.completed; | |
}, | |
isCompleted: function(task) { | |
return task.completed; | |
}, | |
isInProgress: function(task) { | |
return ! this.isCompleted(task) | |
}, | |
deleteTask: function(task) { | |
this.list.splice(this.list.indexOf(task), 1); | |
} | |
}, | |
computed: { | |
remaining: function() { | |
var vm = this | |
return this.list.filter(this.isInProgress).length | |
} | |
} | |
}); | |
new Vue({ | |
el: '#app', | |
data: function () { | |
return { | |
list: null | |
} | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment