I am having trouble with creating the list for bootstrap's ui-typeahead directive:
An $http-call returns the following json:
[{"title":"FOO", "equipment":[{"model":"Model 1"}, {"model":"Model 2"}], "combine":"true"}]
What I need to do is :
- concatenate the title "FOO" to the input the user has already typed in the input field and
- create a list of the equipments : "Model 1" and "Model 2" (the actual dropdown-data) as either 2 separate drop-down items OR concatenate "Model 1" and "Model 2" if "combine" is set to "true" which would yield only ONE drop-down item.
Upon clicking on one of the "equipment" entries in the drop-down I need to call a function which sets the chosen Model in a service object and then calls the $location's url function.
Is this possible?
Here's the template I am using via "typeahead-template-url":
<input typeahead="val for val in autoComplete($viewValue)"
typeahead-template-url="searchAutocompleteTpl.html"
ng-model="query"/>
<script type="text/ng-template" id="searchAutocompleteTpl.html">
<span>found in: </span>
<div ng-repeat="eqp in match.model.equipment">
<a href="" ng-click="showItem(eqp.model)">
{{eqp.model}}
</a>
</div>
</script>