Reputation: 526
I have an array of objects that I use for auto complete, I can successfully make the auto-complete work. Now I also want get masterId from the object(of selected business name) and add it to a div. Im a newbie in Angularjs
<div class="">
<script type="text/ng-template" id="customTemplate.html">
<a>
<span bind-html-unsafe="match.label | typeaheadHighlight:query"></span>
</a>
</script>
<div class="alignhManage">
<input type="text" ng-change="SetupAutoCom(selectedBusiness)"
ng-model="selectedBusiness" placeholder="Search Business"
typeahead="c as c.companyName for c in Business | filter:$viewValue | limitTo:10" typeahead-min-length='2'
typeahead-on-select='onSelectPart($item, $model, $label)'
typeahead-template-url="customTemplate.html"">
</div>
</div>
[{
"masterId": "1541",
"companyName": "HENTIQ ",
"address": { "addressNo": "146" }
}]
Upvotes: 0
Views: 159
Reputation: 5329
When you select the suggested item, typeahead-on-select
is invoked. You can have the logic inside function onSelectPart
by accessing $item
's attributes.
Upvotes: 1