我遇到的问题的值为ng-model
,应用于使用AngularStrap的bs-typeahead
的元素,无法在范围内访问。但是在HTML中可以使用{{ var }}
。AngularStrap的`ng-model` bs-typeahead`在作用域中不可用?
我有以下HTML:
<input type="text" placeholder="add a destination" ng-options="item as item for item in modelTypeahead" ng-model="selectedDestination" bs-typeahead data-template="templates/SrcDstTypeaheadTemplate.html">
我初始化变量在我的控制器:
$scope.selectedDestination = "";
放置一个{{ selectedDestination }}
其他地方中的HTML工作正常。
但是,当我在我的控制器中执行console.log($scope.selectedDestination);
时,它会以空字符串的形式出现。
如果更新我的初始化要的东西,例如:
$scope.selectedDestination = "abc123";
...无论是<input>
和{{ selectedDestination }}
更新适当。我的console.log
也会吐出设定值。但是,如果我更新键入{{ selectDestination }}
将更新,但我的console.log
仍然会吐出'abc123'。
是否有我缺少的范围问题?我不明白{{ selectedDestination }}
是如何输出正确的字符串,但console.log
正在推出一些不同的东西。这几乎看起来我的绑定是单向的,但AngularStrap的bs-typeahead
应该是双向的(根据所有示例)。
遇到完全相同的问题。你解决了吗? –
不。看起来,从前面的选择不会完全传播。我还没有发现究竟如何/为什么。 –