javascript - Show full json set in Angular Material Autocomplete dropdown result on focus -
i filtering json file angular material autocomplete search input; can't seem recreate automatic dropdown json elements on focus demo: angular material demo autocomplete
here's code far :
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 = " "; }]);
the json bit goes this:
var stocks={dowjones30:[{companyname:"3m",stocksymbol:"mmm"}, {companyname:"american express",stocksymbol:"axp"}, {companyname:"apple",stocksymbol:"aapl"}, //etc etc.... {companyname:"wal-mart",stocksymbol:"wmt"}]};
full code on codepen:
after little reduction of original example found out line in html required autocomplete automatically drop down , show items, hope helps else.
md-min-length="0"
Comments
Post a Comment