在动态下拉列表中设置默认值 angularjs

set default value in dynamic dropdown angularjs

请帮我解决我的问题 我对 angularjs 有点陌生,我的问题是我需要能够在 select 选项中设置默认值,当只有一个项目,因为它是一个动态 select 选项,它有另一个包含许多项目的下拉列表,但没关系,当必须使用 ng- 在 select 选项中只 selected 时需要什么选项

                    <select  class="form-control form"  ng-model="relatedTo" style="height: 40px;" ng-options="c.CUSTCODE as c.CUSTNAME + ' - ' + c.CUSTCODE for c in customers | filter:code" >  </select><span style="color:red" ng-show="type === 9 || type !== 9"></span>

ANGULARJS

                    $http.post('commandCenter.aspx/allCustomer', {}).then(
                        function onSuccess(response) {
                            $scope.customers = JSON.parse(response.data.d);
                            console.log($scope.customers); },
                        function onError(response) {
                            console.log('error !!! ');
                        });

1号图这张图还可以,因为他的物品清单很多

2号图当只有一项时,必须默认或selected。

@MrJami 说的。在代码中类似于

                $http.post('commandCenter.aspx/allCustomer', {}).then(
                    function onSuccess(response) {
                        $scope.customers = JSON.parse(response.data.d);
                        if ($scope.customers.length === 1) {
                          $scope.relatedTo = $scope.customers[0].CUSTCODE;
                        }
                        console.log($scope.customers); },
                    function onError(response) {
                        console.log('error !!! ');
                    });