AngularJS Example:
HTML
<link rel="stylesheet" href="http://twitter.github.com/bootstrap/assets/css/bootstrap.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular-ui-bootstrap/1.1.2/ui-bootstrap.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular-ui-bootstrap/1.1.2/ui-bootstrap-tpls.js"></script>
<div ng-app="app">
<h2>Things</h2>
<div ng-controller="TodoCtrl as vm">
<h3>Combined</h3>
<input uib-typeahead="val for val in vm.getThings($viewValue)"
typeahead-template-url="searchAutocompleteTpl.html"
ng-model="query"/>
<script type="text/ng-template" id="searchAutocompleteTpl.html">
<span>found in: {{match.model.title}}{{query}}</span>
<div ng-show="match.model.combine=='true'" ng-repeat="eqp in match.model.equipment">
<a href="" ng-click="showItem(eqp.model)">
{{eqp.model}}
</a>
</div>
<div ng-show="match.model.combine=='false'">
<a href="" ng-click="showItem(eqp.model)" ng-repeat="eqp in match.model.equipment">
{{eqp.model}}
</a>
</div>
</script>
</div>
</div>
CSS
.done-true {
text-decoration: line-through;
color: grey;
}
JavaScript
var app = angular.module('app', ['ui.bootstrap', 'ui.bootstrap.typeahead']);
app
.controller('TodoCtrl', function($scope, $http) {
var vm = this;
vm.things = [{"title":"FOO", "equipment":[{"model":"Model 1"}, {"model":"Model 2"}], "combine":"true"}];
vm.things2 = [{"title":"FOO", "equipment":[{"model":"Model 1"}, {"model":"Model 2"}], "combine":"false"}];
vm.getThings = function (val) {
console.log(val==1);
if(val==1) {
return vm.things;
}
else {
return vm.things2;
}
};
});