没有在控制器中获取位置选择值

Not getting location selected value in controller

我正在使用这个 http://jsfiddle.net/moinsam/SDPHm/light/ 来获取位置。

<input id="searchTextField" type="text" size="50" ng-model=show.location>
<button class="button button-full button-assertive" ng-click="sendReshedule(show)">Reshedule</button>
$scope.sendReshedule = function(data){
console.log(data);
} 

我正在使用输入框搜索位置,当列表出现时我 select 一个位置 但问题是我在文本框中输入的字母只能在控制器中访问,但不能访问实际的 selected 位置。 我无法访问 selected 位置。

例如:我输入“cal”,我得到了一个列表 suggestions.Now I select “加州洛杉矶”。 这个 selection 显示在输入框中,但是当我尝试访问输入框的文本时,我没有得到完整的值,我只得到“cal”。 =12=]

一个快速解决方法是 console.log(document.getElementById('searchTextField').value); vl 继续寻找其他方式。

原因 : Angular 将 show 绑定到 ng-model 然后 show 获取值作为 cal 当你类型,但是当 google 映射 javascript 更新它的值时,即 california 不是 angular 部分,angular 不知道它必须更新它的show ng-model 值,所以你得到它作为 cal ,为此我们使用 $scope.$apply() 但是最近 angular 用猴子补丁修复它。

vl 尝试 post 一段有效的代码,希望这有助于

另一种方法是创建自定义元素:working fiddle for this approach