当下拉单击AngularJS时,表单不会重置

时间:2017-11-26 02:56:33

标签: javascript angularjs

当我点击另一个下拉列表但看起来没有调用vm.reset()函数时,我正在尝试获取两个下拉列表来重置;如果更改下拉列表,我怎样才能调用函数?

<form name="Form1" ng-submit="vm.doSomething()">
    <div layout="row" style="padding-left:30px">
            <select name="Type" ng-model="vm.Type" ng-dropdown type="change" ng-change="vm.reset(Form1)">
                <option value="" disabled selected>Choose</option>
                <option ng-option value="1">1</option>
                <option ng-option value="2">2</option>
                <option ng-option value="3">3</option> 
                <option ng-option value="4">4</option> 
            </select>
    </div>
    <br><br>
    <div class="col-xs-12" id="subType" style="padding-left:30px" ng-if="vm.Type == '1'">
        <label class="col-xs-6 control-label">Sub Type:</label>
        <div class="col-xs-6">
            <select name="subType" ng-model="vm.subType" ng-dropdown required="true">
                <option value="" disabled selected>Choose</option>
                <option ng-option value="sub1">sub1</option>
            </select>
        </div>
    </div>
    <div class="col-xs-12" id="subType" style="padding-left:30px" ng-if="vm.Type == '2'">
        <label class="col-xs-6 control-label">Sub Type:</label>
        <div class="col-xs-6">
            <select name="subType" ng-model="vm.subType" ng-dropdown required="true">
                <option value="" disabled selected>Choose</option>
                <option ng-option value="sub2">sub2</option>
            </select>
        </div>
    </div>
</form>
$scope.reset = function(form) {
    vm.ResetThisDropDown1 = undefined;
    vm.ResetThisDropDown2 = undefined;
}

0 个答案:

没有答案