Skip to content

Instantly share code, notes, and snippets.

@toddboom
Last active December 21, 2015 11:59
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 toddboom/6302919 to your computer and use it in GitHub Desktop.
Save toddboom/6302919 to your computer and use it in GitHub Desktop.
App = Ember.Application.create()
App.AutocompleteController = Ember.Controller.extend(
searchText: null
searchResults: ->
searchText = @get("searchText")
return unless searchText
regex = new RegExp(searchText, "i")
["one", "two", "three"].filter (name) ->
name.match regex
.property("searchText")
)
<script type="text/x-handlebars">
<h2>Welcome to Ember.js</h2>
{{outlet}}
</script>
<script type="text/x-handlebars" data-template-name="index">
{{render "autocomplete"}}
</script>
<script type="text/x-handlebars" data-template-name="autocomplete">
{{input type="text" value=searchText placeholder="Search..."}}
<ul>
{{#each searchResults}}
<li>{{this}}</li>
{{/each}}
</ul>
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment