【发布时间】:2017-09-30 05:23:56
【问题描述】:
<select id="e1" style="width:100%" ui-select2 tabindex="-1" ng-init="GetAllAgent()" ng-model="Agent" ng-options="ctr as ctr.AgentName for ctr in ListAgent track by ctr.AgentId" ng-change="GetSubAgentList(Agent.AgentId)">
<option value=""> </option></select>
当它处于编辑模式时,无法使用下面的代码设置默认值
angular.forEach($scope.ListAgent, function (value, index) {
if (value.AgentId == HR.AgentId) {
$scope.Agent = $scope.ListAgent[index];
}
})
$scope.ListAgent= [{ AgentId: "0", AgentName:"Ann" }, { AgentId: "1", AgentName:"Muh" }];
和
HR.AgentId=1
【问题讨论】:
-
请发帖
$scope.ListAgent和HR.AgentId或在Plunker 中发布演示 -
Questn 已编辑。如果有任何 anthr 方法来设置 dropdwn 值请分享
标签: angularjs ui-select ui-select2 angular-ui-select