我的页面中有一个文本框,其中包含自定义自动完成指令:
<input type="text" auto-complete ng-model="variant" value="{{variant}}"/>
我遇到的问题是,当用户从自动完成菜单中选择一个值时,ng-model不会更新。
我决定在ng-blur指令中更改模型。我试过了:
<input type="text" auto-complete ng-blur="variant=element.value" ng-model="variant" value="{{variant}}"/>
那不起作用。有没有办法在不编写自定义指令的情况下完成此任务?
答案 0 :(得分:0)
试试这个:
<input type="text" auto-complete ng-blur="variant=$event.target.value" ng-model="variant" value="{{variant}}"/>
这是 working demo