为什么Angular Drop down总是有效

时间:2016-06-30 14:35:26

标签: javascript angularjs dropdown

你能告诉我为什么下面的下拉总是说有效吗?换句话说,没有选择任何有效的内容。required属性不起作用。

JS

 vm.foreclosureActionHeader = {};

HTML

<form name="foreclosureActionsForm" role="form" novalidate class="form-validation left-aligned">
     <select id="refereeNameDropDown" name="refereeNameDropDown" required
        ng-options="a.id as a.firstName + ' ' + a.lastName for a in vm.referees"
        ng-model="vm.foreclosureActionHeader.refereeId"
        ui-jq="selectpicker"
        ui-options='{ iconBase: "famfamfam-flag", tickIcon: "fa fa-check" }'
        data-live-search="true" title="@L("SelectRefereeName")">
        <option value=""></option>
     </select>
</form>

我使用了上述答案中提到的相同方式。但它仍然不起作用。你能告诉我为什么吗?

1 个答案:

答案 0 :(得分:0)

我找到了解决方案。欢呼:D

<强> JS

vm.init = function () {
if (vm.foreclosureActionHeader.refereeId == 0) vm.foreclosureActionHeader.refereeId = null;
}

vm.init();