【发布时间】:2017-04-27 05:13:16
【问题描述】:
我无法使用 ui-typeahead 从自定义模板内部调用控制器函数:
<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 ng-repeat="eqp in match.model.equipment"/>
<a href="" ng-click="showItem(eqp.model)">
found in: {{eqp.model}}
</a>
</script>
问题是模板中好像没有控制器的作用域:
showItem(eqp.model)
永远不会被调用。我也试过:
$parent.showItem(eqp.model)
无济于事。
那我怎样才能在控制器的作用域上调用函数/值呢?
【问题讨论】:
标签: angularjs angular-ui-bootstrap