我有一组用于自动完成的对象,我可以成功完成自动完成工作。现在我还想从对象(选定的商业名称)中获取masterId并将其添加到div中。我是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" }
}]
答案 0 :(得分:1)
选择建议的项目时,会调用typeahead-on-select
。通过访问onSelectPart
的属性,您可以在函数$item
中拥有逻辑。