Last active
August 29, 2015 14:24
-
-
Save koriroys/024775c69778732e83dc to your computer and use it in GitHub Desktop.
New Twiddle
This file contains hidden or 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
export default Ember.Controller.extend({ | |
appName:'Ember Twiddle', | |
queryParams: ['query'], | |
query: null, | |
queryField: Ember.computed.oneWay('query'), | |
actions: { | |
search: function() { | |
this.set('query', this.get('queryField')); | |
} | |
} | |
}); |
This file contains hidden or 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
var words = "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ab illum labore quis ipsam voluptate sunt reprehenderit iure nisi sit ut inventore illo porro. Eveniet odio sed corporis distinctio tempore temporibus!".toLowerCase().split(' '); | |
export default Ember.Route.extend({ | |
queryParams: { | |
query: { | |
// Opt into full transition | |
refreshModel: true | |
} | |
}, | |
model: function(params) { | |
if (!params.query) { | |
return []; // no results; | |
} | |
var regex = new RegExp(params.query); | |
return words.filter(function(word) { | |
return regex.exec(word); | |
}); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment