gpt4 book ai didi

javascript - ui-select 选择在 angularjs 中不起作用

转载 作者:行者123 更新时间:2023-11-28 06:10:17 25 4
gpt4 key购买 nike

我目前正在 AngularJS 中使用 ui-select 组件。

<ui-select ng-model="tipData.category" search-enabled="false" name="category" required="required" class="orange-site-color-select custom-select">
<ui-select-match><span class="ui-select-result">{{$select.selected}}</span></ui-select-match>
<ui-select-choices repeat="tipcat in tipCategory"><span ng-bind-html="tipcat.name"></span></ui-select-choices>
</ui-select>

我想知道如何实现 ui-select 中显示的自动选择值作为从数据库检索数据(仅 id)并显示在 ui-选择

最佳答案

试试这个

<div ng-controller="DemoCtrl" ng-app="main">
<select ng-model="selectedCountry">
<option value="">Select Account</option>
<option ng-repeat="x in chooseCountries" value="{{x.countryId}}" >{{x.name}}</option>
</select>
</div>

和脚本代码

 var app = angular.module('main', []);
app.controller('DemoCtrl', function ($scope) {
$scope.chooseCountries=[
{countryId : 1, name : "France - Mainland", desc: "some description" },
{countryId : 2, name : "Gibraltar", desc: "some description"},
{countryId : 3, name : "Malta", desc: "some description"}
];
$scope.selectedCountry = $scope.chooseCountries[1].countryId.toString();
});

关于javascript - ui-select 选择在 angularjs 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36469350/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com