Javascript Angular UI引导typeahead-promise解析时更新模型
我使用并希望在承诺解决时更新它的模型 我在select上使用Javascript Angular UI引导typeahead-promise解析时更新模型,javascript,angularjs,angular-ui-bootstrap,Javascript,Angularjs,Angular Ui Bootstrap,我使用并希望在承诺解决时更新它的模型 我在select上使用typeahead属性,如下所示 typeahead-on-select="select($item,$model))" 在select($item,$model)中,正在进行一些异步操作,当promise解析时,我希望根据结果设置模型的值 promise.then(function (result) { $model.name = result; console.log($model); // <-- $mo
typeahead属性,如下所示
typeahead-on-select="select($item,$model))"
在select($item,$model)
中,正在进行一些异步操作,当promise
解析时,我希望根据结果设置模型的值
promise.then(function (result) {
$model.name = result;
console.log($model); // <-- $model IS updated but the view doesn't react on it
}
promise.then(函数(结果){
$model.name=结果;
console.log($model);//首先,您使用的是什么angular和ui.bootstrap版本?几周前我遇到了同样的问题并找到了解决方案!ui.bootstrap 0.12.0@user2992420我想我已经找到了问题所在。我想,typeahead中的$model在select($item,$model,$label)上是
是typeahead模型。但它可能是列表中特定项的模型。更新此模型不是我试图做的事情。现在我将模型变量的名称发送到函数,并像这样更新模型$scope[modelName]=result
。可能不是最佳解决方案,但它正在工作-我可以继续:)能否尝试在ng模型属性中使用$parent.modelName而不是modelName?有一个bug可以通过此方法解决。如果我这样做,它将指向错误的范围。您指的是什么bug?是否有链接?