相关疑难解决方法(0)

从Bootstrap-UI Typeahead模板访问控制器范围

我无法使用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)

无济于事.

如何调用控制器范围内的函数/值呢?

angularjs angular-ui-bootstrap

14
推荐指数
1
解决办法
4012
查看次数

如何迭代一个对象数组以进行typeahead?

http://angular-ui.github.io/bootstrap/

我想使用bootstrap的typeahead,并在对象中搜索两个不同的键对.如何迭代数组对象?

也有人可以解释这是什么? typeahead="state for state in states | filter:$viewValue"

for条款让我失望,似乎真的不清楚因为state for state有相同的名字.

angularjs angular-ui-bootstrap

3
推荐指数
1
解决办法
1万
查看次数

标签 统计

angular-ui-bootstrap ×2

angularjs ×2