在ng-repeat上将选择默认值设置为空

时间:2018-02-19 17:42:28

标签: angularjs

我有这个选择,我需要默认值为空,尝试添加一个值为“?”的选项并选择=“选中”,但它不会工作,任何想法?

<select class="form-control" 
        id="Select7" 
        name="grossweightmeasurementunitcode" 
        ng-model="itemForm.grossweightmeasurementunitcode" 
        ng-required="true">
        <option ng-repeat="unidadepeso in unidadespeso" value="{{unidadepeso.commoncode}}">{{unidadepeso.sigla}}</option>
 </select>

1 个答案:

答案 0 :(得分:0)

试试这个:

<select 
                        class="form-control" 
                        id="Select7" 
                        name="grossweightmeasurementunitcode" 
                        ng-model="itemForm.grossweightmeasurementunitcode" 
                        ng-required="true">
<option value="">--Select--</opton>
                            <option ng-repeat="unidadepeso in unidadespeso" value="{{unidadepeso.commoncode}}">{{unidadepeso.sigla}}</option>
                    </select>