Skip to content

Instantly share code, notes, and snippets.

@freshcutdevelopment
Created February 14, 2016 14:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save freshcutdevelopment/9d619eb252b2f6524f1b to your computer and use it in GitHub Desktop.
Save freshcutdevelopment/9d619eb252b2f6524f1b to your computer and use it in GitHub Desktop.
Todo View-Model
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