在下面的函数中,我得到了响应和长度perfiosAnalysisData
function getPerfiosData() {
var tribeId = vm.currentTribeId;
getPerfiosAnalysisData(tribeId).then(function(response){
vm.perfiosAnalysisData = response.data;
/* Check Select Option Length */
$scope.lengthData = vm.perfiosAnalysisData.institutions.length;
/* Check Select Option Length */
vm.isPerfiosEnabled = response.is_enabled;
setChartDataConfig();
getDrawGraph();
},function(err){
if(err.status === 412) {
vm.perfiosNotPermitted = true;
}
});
}
因此,如果长度为 1,我想自动选择选项并调用 ng-change 函数。
<select class="perf-select" ng-model="viewProfileCtrl.monthsForm.institution"
ng-options="inst.institution.institution_id as inst.institution.name for inst in viewProfileCtrl.perfiosAnalysisData.institutions"
ng-change="viewProfileCtrl.setCurrMonthInsti(viewProfileCtrl.monthsForm.institution)">
<option value="" selected>Select a Bank
</select>
如何做到这一点?