https://github.com/gmurphey/ember-search-helper
Provides a helper to filter an array by a partial search string.
https://github.com/gmurphey/ember-search-helper
ember ember-addon
Last synced: about 1 year ago
JSON representation
Provides a helper to filter an array by a partial search string.
- Host: GitHub
- URL: https://github.com/gmurphey/ember-search-helper
- Owner: gmurphey
- License: other
- Created: 2017-08-03T03:27:37.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2022-12-09T13:31:33.000Z (over 3 years ago)
- Last Synced: 2025-03-07T05:17:45.816Z (over 1 year ago)
- Topics: ember, ember-addon
- Language: JavaScript
- Homepage: https://gmurphey.github.io/ember-search-helper
- Size: 2.42 MB
- Stars: 7
- Watchers: 1
- Forks: 0
- Open Issues: 35
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.md
Awesome Lists containing this project
README
# ember-search-helper
[](https://travis-ci.org/gmurphey/ember-search-helper) [](https://greenkeeper.io/)
Provides a helper to filter an array by a partial search string.
## Compatibility
* Ember.js v3.4 or above
* Ember CLI v2.13 or above
## Examples
The `search` helper can filter simple arrays:
```javascript
// controller.js
export default Ember.Controller.extend({
fruits: ['Apple', 'Banana', 'Orange']
query: 'Oran'
});
```
```hbs
{{input value=query on-key-press=(action (mut query))}}
- {{fruit}}
{{#each (search query fruits) as |fruit|}}
{{/each}}
```
And arrays of objects:
```javascript
// controller.js
export default Ember.Controller.extend({
fruits: [
{
name: 'Apple',
opinion: 'Meh'
},
{
name: 'Orange',
opinion: 'Yay'
},
{
name: 'Banana',
opinion: 'Nay'
}
],
searchProperties: ['name', 'opinion'],
query: 'ay'
});
```
```hbs
{{input value=query on-key-press=(action (mut query))}}
- {{fruit.name}}
{{#each (search query fruits properties=searchProperties) as |fruit|}}
{{/each}}
```
### Options
- `properties` (`Array`, default: `[]`)
An array of properties you would like to search by. Only useful if you are searching an array of objects.
- `caseSenstive` (`Boolean`, default: `false`)
When set to true, the `search` helper will only return results where the case of the query matches.
- `exactMatch` (`Boolean`, default: `true`)
When set to true, the `search` helper will only return results where the query matches the string exactly.
Contributing
------------------------------------------------------------------------------
See the [Contributing](CONTRIBUTING.md) guide for details.
License
------------------------------------------------------------------------------
For more information on using ember-cli, visit [https://ember-cli.com/](https://ember-cli.com/).