Created
February 14, 2016 14:52
-
-
Save freshcutdevelopment/9d619eb252b2f6524f1b to your computer and use it in GitHub Desktop.
Todo View-Model
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
import {inject, bindable} from 'aurelia-framework'; | |
import {TodoApi} from './todoapi'; | |
@inject(TodoApi) | |
export class App{ | |
@bindable todoItems = []; | |
@bindable searchTerm = ""; | |
constructor(todoApi){ | |
this.status = "ready"; | |
this.todoApi = todoApi; | |
} | |
bind(){ | |
this.todoApi.list().then(todoItems =>{ | |
this.todoItems = todoItems; | |
}); | |
} | |
clearFilter(){ | |
this.searchTerm = ""; | |
} | |
filterFunc(searchExpression, value){ | |
let itemValue = value.text; | |
if(!searchExpression || !itemValue) return false; | |
return itemValue.toUpperCase().indexOf(searchExpression.toUpperCase()) !== -1; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment