UI Bootstrap Typeahead 不在 ng-model 中存储选择
UI Bootstrap Typeahead doesn't store selection in ng-model
好的,所以我正在使用 Ui-Bootstrap typeahead (https://angular-ui.github.io/bootstrap/#/typeahead)。
我正在为数据使用 firebase 数组。
当我开始输入时,我已经知道它会过滤结果,我可以单击一个。
当我点击它时,它似乎没有在模型中存储 selected 值。
我做错了什么?
我只想在 select 之后将其保存在 ng-model 中。
<pre>{{newLink | json}}</pre>
<input type="text" ng-model="newLink" placeholder="Search for Pages" uib-typeahead="title as page.title for page in admin.content | filter: {title: $viewValue}" typeahead-show-hint="true" class="form-control"/>
我的数据看起来像这样(缩短)
...
{
title: 'Home',
url: 'home',
published: true,
html: ''
}
...
这是一个简短的视频,它准确地展示了我的问题:https://www.dropbox.com/s/nt2c5wxx9lbuy5v/Problem%201.mov?dl=0
更新
如果我把上面uib-typeahead
中的title as page.title for page in admin.content
改成page.title for page in admin.content
。一切都像预期的那样工作 EXCEPT ng-model 只代表标题而不是数组。我真的需要 firebase uid 和标题。
更新 2
如果我再次将 uib-typeahead
更改为 page for page in admin.content
我会在 ng-model 中得到我想要的内容,除了 typeahead 选项列为 [object Object].
按照要求,这完全是正确构建 select 指令的问题,我们能够弄清楚它应该是:
<input type="text"
ng-model="newLink"
placeholder="Search for Pages"
uib-typeahead="page as page.title for page in admin.content | filter: {title: $viewValue}"
typeahead-show-hint="true"
class="form-control"/>
好的,所以我正在使用 Ui-Bootstrap typeahead (https://angular-ui.github.io/bootstrap/#/typeahead)。
我正在为数据使用 firebase 数组。
当我开始输入时,我已经知道它会过滤结果,我可以单击一个。
当我点击它时,它似乎没有在模型中存储 selected 值。
我做错了什么?
我只想在 select 之后将其保存在 ng-model 中。
<pre>{{newLink | json}}</pre>
<input type="text" ng-model="newLink" placeholder="Search for Pages" uib-typeahead="title as page.title for page in admin.content | filter: {title: $viewValue}" typeahead-show-hint="true" class="form-control"/>
我的数据看起来像这样(缩短)
...
{
title: 'Home',
url: 'home',
published: true,
html: ''
}
...
这是一个简短的视频,它准确地展示了我的问题:https://www.dropbox.com/s/nt2c5wxx9lbuy5v/Problem%201.mov?dl=0
更新
如果我把上面uib-typeahead
中的title as page.title for page in admin.content
改成page.title for page in admin.content
。一切都像预期的那样工作 EXCEPT ng-model 只代表标题而不是数组。我真的需要 firebase uid 和标题。
更新 2
如果我再次将 uib-typeahead
更改为 page for page in admin.content
我会在 ng-model 中得到我想要的内容,除了 typeahead 选项列为 [object Object].
按照要求,这完全是正确构建 select 指令的问题,我们能够弄清楚它应该是:
<input type="text"
ng-model="newLink"
placeholder="Search for Pages"
uib-typeahead="page as page.title for page in admin.content | filter: {title: $viewValue}"
typeahead-show-hint="true"
class="form-control"/>