I'm currently working on filtering a JSON file for an Angular Material Autocomplete search input, but I can't quite get the automatic dropdown with all the JSON elements to show up like in this demo: Angular Material Demo Autocomplete
Here's what my code looks like at the moment:
HTML:
<md-autocomplete
md-search-text="searchText"
md-items="item in items | filter:searchText"
md-item-text="item.companyName + space + item.stockSymbol"
placeholder="Type Company Name or Stock Symbol">
<span md-highlight-text="searchText">{{ item.companyName }} {{ item.stockSymbol }}</span>
</md-autocomplete>
JS:
app.controller('ctrl', ['$scope', function($scope) {
$scope.items = stocks.DowJones30;
$scope.searchText = '';
$scope.space = " ";
}]);
This is how the JSON data is structured:
var stocks={DowJones30:[{companyName:"3M",stockSymbol:"MMM"},
{companyName:"American Express",stockSymbol:"AXP"},
{companyName:"Apple",stockSymbol:"AAPL"},
//and so on....
{companyName:"Wal-Mart",stockSymbol:"WMT"}]};
You can view the full code on Codepen: