【问题标题】:Bootstrap select picker with ng-repeat is not working for JSON object带有 ng-repeat 的引导选择选择器不适用于 JSON 对象
【发布时间】:2023-03-15 05:15:01
【问题描述】:

我使用 Bootstrap 选择进行搜索和多项选择,但问题是当我在 ng-repeat 中使用 $scope 对象作为选项时,它不起作用。我在下面给出了我的代码。

<select name="name" ng-model="city.id" class="selectpicker" data-live-search="true" ng-options="o._id as o.name for o in stateList" ></select>

<select name="name" ng-model="city.id" class="selectpicker" data-live-search="true" ><option ng-repeat="option in stateList" value="{[{option._id}]}">{[{option.name}]}</option>

我已经使用了 options 和 ng-option 方法,但仍然没有显示对象...

这是我需要在选择中重复的状态对象...

$scope.stateList = [{"_id":"1","name":"www"},{"_id":"2","name":"bgg"}]

希望您了解我的问题,如果您需要更多详细信息 请发表评论,我正在等待您的建议...

【问题讨论】:

  • 你能在这里写下你的完整代码结构吗...
  • 现在可以为您提供代码吗@AnilKumarRam
  • 当我使用像 $scope.value = ['1','2','3']; 这样的数组时我可以在 ng-repeat 中获取值,它显示在下拉列表中,但是当我使用对象执行此操作时,没有显示。
  • 我已经为你创建了小提琴检查并回复jsfiddle.net/fA968/257
  • 如您所知,我使用 bootstrap-select 和 angularjs 进行搜索并在下拉列表中选择,因此您共享的小提琴包含 angularjs 中的正常下拉列表...请查看此链接以获取示例下拉列表silviomoreto.github.io/bootstrap-select/examples/#live-search 并且我正在使用搜索进行多项选择...

标签: angularjs twitter-bootstrap angularjs-scope angular-ui-bootstrap


【解决方案1】:

我也遇到了问题,但使用 nya-bootstrap-select http://nya.io/nya-bootstrap-select/#!/

修复它。它与 bootstrap select 对 jQuery 的使用有关,而 jQuery 并不总是与 Angular 配合得很好……这是用 Angular 编写的,可与 Angular 一起使用,因此它更兼容……

【讨论】:

  • 我使用了 UI-Select 而不是上面运行良好的代码......正如你所说的问题可能出在 JQuery @MattE
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2023-03-05
  • 1970-01-01
  • 2013-05-25
相关资源
最近更新 更多