I'm currently utilizing the Angular UI Typeahead directive available at this link. Can someone provide guidance on how to assign a model as an id and display text as a name in it? I have attempted the method below but encountered issues. Any suggestions on how to proceed would be greatly appreciated. Thank you.
Note : To test, please input either a
or k
into the code pen provided below.
JS Snippet
var states=[{'id':1,'name':'Alabama'},{'id':2,'name':'Kansas'}]
HTML Structure
<input name="states" id="states" type="text" placeholder="enter a state" ng-
model="selected" typeahead="a.id as a.name for a in states | filter:$viewValue"
class="form-control">