从下拉列表中获取数据库中的值

时间:2016-03-15 06:48:17

标签: javascript angularjs

这是我的代码:

<ui-select ng-model="apptDetails.profile" name="profile" theme="bootstrap" ng-required="true">
   <ui-select-match placeholder="Select Profile" >{{$select.selected.Profile_name}}
   </ui-select-match>
   <ui-select-choices
       repeat="profile.Profile_id as profile in profileList | filter: $select.search">
        <span ng-bind-html="profile.Profile_name | highlight: $select.search" ></span>
  </ui-select-choices>
</ui-select>

我需要从数据库获取值并且它已经显示在下拉列表中,我在ng-model中获取值但是它不能在下拉列表中设置(不在选项中)但是如果我发送帖子请求它可以工作。

例如:如果特定用户的数据库中的配置文件是abc,它将显示在预先选择的下拉列表中。当我在表单中获得该用户的信息时,所有文本字段都从模型中获取数据,但它不能显示在下拉列表中。

2 个答案:

答案 0 :(得分:1)

你可能做错了......当我在plunker上创建一个演示时,它的工作正常。 可能它可以帮助你...

https://plnkr.co/edit/43ToW4?p=preview

答案 1 :(得分:0)

尝试使用ng-repeat

  <ui-select-choices
   repeat="profile in profileList | filter:$select.search">
    <span ng-bind-html="profile.Profile_name | highlight: $select.search" >     </span>
   </ui-select-choices>
相关问题