I am new to angular js. I am trying to implement typeahead for the json data I get: format of json data is like:
$scope.utilstates = [
{ "State": "Florida", "Key": "FL", "Utility": [ "Bartow (City of) Electric", "Clay Electric Co-Op", "Florida Power & Light", "FMG", "Gainesville Regional Utilities", "Gulf Power Company" ] },
{ "State": "Texas", "Key": "TX", "Utility": [ "AEP-Texas (SWEPCO)", "Austin Energy", "Brownsville Public Utilities Board (TX)", "CenterPoint Energy (Reliant - HL&P)"] },
{ "State": "Virginia", "Key": "VA", "Utility": [ "DVP", "NOVEC"] }
];
In the html, I want the user to enter the utility company irrespective of state and should show the matching utility company.
in html, I have this code:
<input type="text" ng-model="query.utility" typeahead="st as st.Utility for st in utilstates | filter:({Utility:$viewValue}) | limitTo:8" class="form-control" placeholder="Utilities">
But I get complete array of values, instead of selected value from the matched array.
Any help would be greatly appreciated.
Plunker link: http://plnkr.co/edit/no0hATW5mHiIbuON6B9E?p=preview