angularjs 自动 select 下拉

angularjs auto select drop down

在下面的函数中,我得到了 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,我想自动 select 选项并调用 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>

如何实现?

如果 lengthData 等于 1 然后将第一个对象分配给 ng 模型变量并像这样调用 ng 更改函数

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;


        if ($scope.lengthData === 1) {
            $scope.viewProfileCtrl.monthsForm.institution = $scope.viewProfileCtrl.perfiosAnalysisData.institutions[0];
            $scope.viewProfileCtrl.setCurrMonthInsti($scope.viewProfileCtrl.monthsForm.institution);
        }


        /* Check Select Option Length */
        vm.isPerfiosEnabled = response.is_enabled;
        setChartDataConfig();
        getDrawGraph();
    }, function(err) {
        if (err.status === 412) {
            vm.perfiosNotPermitted = true;
        }
    });
}