angular-正式发布 ui-select
angular-formly issue with ui-select
我正在尝试将 Angular-Formly 与 angular ui-select 一起使用,使用 $http 获取结果。
选项应在用户输入时刷新。当我从另一个文本输入设置模型时,ui-select 会正确更新并根据输入的内容显示相应的结果文本框。
然而,当我直接输入 ui-select 框时,我没有取回值并且 templateOptions.options 函数没有触发并且 $viewvalue
是未更新。
我似乎也无法访问已更新但在 expressionProperties 中不可用的 $select.search
结果。
请查看以下重现错误的 JSBin:
http://jsbin.com/peducofaje/edit
我将不胜感激。
我提前给你准备了一份圣诞礼物。我已经更新 the ui-select example 以完全满足您的需求 :-) 关于为什么您的方法不起作用的几点说明:
- expressionProperties only 运行 when the
formState
or model
changes which is an optimization to reduce watchers numbers (because all expressionProperties share a single watcher).这样做的问题是,您的模型直到选择了一个选项后才得到更新,所以是的。
- 模板使用了
group-By
,但 templateOptions
没有 groupBy
。如果 templateOptions
上存在 templateManipulator
,您可以使用 templateManipulator
动态添加 group-by
,但我的解决方案并未演示这一点。
- 您没有处理地址搜索为空的情况
此外,请查看顶部的注释:
// NOTE: This next line is highly recommended. Otherwise Chrome's autocomplete will appear over your options!
formlyConfig.extras.removeChromeAutoComplete = true;
希望对您有所帮助!
我正在尝试将 Angular-Formly 与 angular ui-select 一起使用,使用 $http 获取结果。
选项应在用户输入时刷新。当我从另一个文本输入设置模型时,ui-select 会正确更新并根据输入的内容显示相应的结果文本框。
然而,当我直接输入 ui-select 框时,我没有取回值并且 templateOptions.options 函数没有触发并且 $viewvalue
是未更新。
我似乎也无法访问已更新但在 expressionProperties 中不可用的 $select.search
结果。
请查看以下重现错误的 JSBin:
http://jsbin.com/peducofaje/edit
我将不胜感激。
我提前给你准备了一份圣诞礼物。我已经更新 the ui-select example 以完全满足您的需求 :-) 关于为什么您的方法不起作用的几点说明:
- expressionProperties only 运行 when the
formState
ormodel
changes which is an optimization to reduce watchers numbers (because all expressionProperties share a single watcher).这样做的问题是,您的模型直到选择了一个选项后才得到更新,所以是的。 - 模板使用了
group-By
,但templateOptions
没有groupBy
。如果templateOptions
上存在templateManipulator
,您可以使用templateManipulator
动态添加group-by
,但我的解决方案并未演示这一点。 - 您没有处理地址搜索为空的情况
此外,请查看顶部的注释:
// NOTE: This next line is highly recommended. Otherwise Chrome's autocomplete will appear over your options!
formlyConfig.extras.removeChromeAutoComplete = true;
希望对您有所帮助!