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

Get values from database in drop down

本文关键字:获取 数据库 下拉列表      更新时间:2023-09-26

这是我的代码:

<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 中获取值,但无法在下拉列表中设置(不在选项中),但是如果我发送 post 请求,它可以工作。

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

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

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

试试这个 ng-repeat(英语: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>