This is what I have so far. The search input field is rendered in the hbs template fine. But the moment I start typing into it, nothing happens. What am I missing? Any pointers would be appreciated.
// ui/app/routes/application.js
import Ember from 'ember';
export default Ember.Route.extend({
model: function() {
return Ember.RSVP.hash({
orders: this.store.find('order'),
products: this.store.find('product', { status: 'available' })
});
},
});
// ui/app/controllers/application.js
import Ember from 'ember';
export default Ember.ObjectController.extend({
products: function() {
console.log('adf');
if (this.get('search')) {
return this.get('searchedProducts');
} else {
return this.get('products');
}
}.property('search', 'searchedProducts'),
searchedProducts: function() {
var search = this.get('products').toLowerCase();
return this.filter(function(product) {
return product.get('name').toLowerCase().indexOf(search) !== -1;
});
}.property('search', 'products.@each.name'),
});
// ui/app/templates/application.js
<br />{{input type="text" value="search" placeholder="search" class="search"}}
{{outlet}}
Aucun commentaire:
Enregistrer un commentaire