我使用ng-options在选择框中显示数据,但在选项中我有一个硬编码值是No-search如何显示该值首先选择

时间:2021-03-20 01:03:07
<div class="filter-box">
    <select ng-model="$ctrl.customModel" 
            ng-options= 'option.id as option.name for option in transactionstatusList'
            ng-change="transactionStatusChange()"> 
        <option value="" selected="selected">No Search</option>
    </select> 
</div>

I am using angularjs ng-options to show data in select box but in option i have one hard-coded value is No-search how to show that value select at first because when data comes dynamically it shows first value from the data

我使用angularjs ng-options在选择框中显示数据但是在选项中我有一个硬编码值是No-search如何首先显示该值选择因为当数据动态出现时它显示数据的第一个值

1 个解决方案

#1


0  

Your code should work well if you have undefined customModel.

如果您有未定义的customModel,您的代码应该可以正常工作。

$scope.customModel;

Demo 1

演示1

However, if $scope.customModel is predefined, after async call, selected option jumps regards to ng-model

但是,如果预定义了$ scope.customModel,则在异步调用之后,选定的选项跳转会关注ng-model

Demo 2

演示2

#1


0  

Your code should work well if you have undefined customModel.

如果您有未定义的customModel,您的代码应该可以正常工作。

$scope.customModel;

Demo 1

演示1

However, if $scope.customModel is predefined, after async call, selected option jumps regards to ng-model

但是,如果预定义了$ scope.customModel,则在异步调用之后,选定的选项跳转会关注ng-model

Demo 2

演示2