I'm new to angularJs and want to filter the search result.
Here is the example : https://codepen.io/anon/pen/mpJyKm
I want search result based on query input filtered such as string starts with come first in the result list and then contains. I'm using md-autocomplete example and want to filter list in controller only.
e.g. If search input is : A
then result should be like this :
Alabama
Alaska
Arizona
Arkansas
California
Colorado
...
tried this for filtering result but returning Starts with or contains in any order without filtering as I need:
function createFilterFor(query) {
var lowercaseQuery = angular.lowercase(query);
return function filterFn(state) {
return (state.value.indexOf(lowercaseQuery) != -1);
};
}