0
votes

what i basically done is sorted my content according to some properties and used arrangedContent so that i can get the sortedcontent. Now i want to filter my model using some keys in model(eg:name) and want only that content to display in template.what i want is when i type some name in the search field text box,the content should be filtered and controller will only have to display the filtered content with my sorting properties applied.

{{#each arrangedContent}}......{{/each}}
{{input type="text" action="search" valueBinding="criteria"  placeholder="Search"}}

when i enter the name,the model should be filtered and arrangedContent should only display that filtered content I am a beginner in ember and cant find a way to do the above thing.

1

1 Answers

0
votes

I implemented a similar case. Keeping use of the arrangedContent.

filteredContent: function(){
    var content = this.get('arrangedContent');
    // perform criteria on content
    // e.g.: content.findBy('name', criteria)
    return content;
}.property('arrangedContent.@each', 'criteria')

Your handlebars template:

{{#each filteredContent}}......{{/each}}
{{input type="text" action="search" valueBinding="criteria"  placeholder="Search"}}

You will keep the advantages off arrangedContent, whilst still being able to modify it.