Angular UI Bootstrap 自定义预输入模板中的范围变量

Angular UI Bootstrap scope variables in custom typeahead template

我正在使用 UI Bootstrap 的 typeahead 指令,并通过 typeahead-popup-template-url 添加了我自己的弹出模板。在该模板中,我想从父模板(即我使用 typeahead 指令的模板)访问范围变量。这可能吗?

这是我正在尝试做的(损坏的)示例("hello" 应该出现在下拉列表中):http://plnkr.co/edit/ITT1SdRfUWeeN6n3aMqu?p=preview

我想在不修改 typeahead 指令的情况下执行此操作。如果有更优雅的解决方案,我不想在第三方 (uib) 代码中乱搞。

Bootstrap, jquery ui, 剑道ui, yui 等 是不是框架有点多O.o

无论如何,这个 post 可能会有所帮助:How to access parent scope from within a custom directive *with own scope* in AngularJS?

在您的模板中,您需要引用 $parent 范围。变化:

This should say "hello": {{hello}}</h1>

收件人:

This should say "hello": {{$parent.hello}}</h1>