我无法使用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>
Run Code Online (Sandbox Code Playgroud)
问题是模板中似乎没有控制器的范围:
showItem(eqp.model)
永远不会被称为.我也尝试过:
$parent.showItem(eqp.model)
无济于事.
如何调用控制器范围内的函数/值呢?
http://angular-ui.github.io/bootstrap/
我想使用bootstrap的typeahead,并在对象中搜索两个不同的键对.如何迭代数组对象?
也有人可以解释这是什么?
typeahead="state for state in states | filter:$viewValue"
该for条款让我失望,似乎真的不清楚因为state for state有相同的名字.