Skip to content

Instantly share code, notes, and snippets.

@trek
Last active December 21, 2015 13:29
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save trek/6312601 to your computer and use it in GitHub Desktop.
Save trek/6312601 to your computer and use it in GitHub Desktop.
<script type="text/x-handlebars">
<h2>Welcome to Ember.js</h2>
{{input type="text" value=searchText placeholder="Search..."}}
<ul>
{{#each searchResults}}
<li>{{this}}</li>
{{/each}}
</ul>
</script>
App = Ember.Application.create();
App.ApplicationController = Ember.Controller.extend({
searchResults: function() {
var searchText = this.get("searchText");
if (!searchText) {return; }
var regex = new RegExp(searchText, "i");
return ["one", "two", "three"].filter(function(name){
return name.match(regex);
});
}.property("searchText")
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment