具有 ng-disable 表达式时如何从控制器启用 md-button?

How to enable md-button from controller when it is having ng-disable expression?

我的表单中有一个 md 按钮,我正在使用 ng-disable 表达式设置它。一切正常。但现在我想在控制器的特定条件下启用按钮。 我是这样设置的

vm.verifyMobileForm.$invalid = true;

但这对我不起作用。

这是我的元素

<form name="verifyMobileForm" novalidate>
    <md-input-container class="md-block" md-no-float>
        <input type="mobile" id="mobile" ng-value="{{vm.form.mobile}}" 
                name="mobile" ng-model="vm.form.mobile" 
                placeholder="Your Mobile number" 
                ng-pattern="/^[789]\d{9}$/" maxlength="10" required
        />
        <div ng-messages="verifyMobileForm.mobile.$error" role="alert" multiple>
            <div ng-message="required">
                <span >Mobile no. is required</span>
            </div>

        </div>

    </md-input-container>
    <div class="dialog-demo-content" layout="row" layout-wrap layout-margin layout-align="center">
        <md-button type="submit" 
              class="md-raised md-accent submit-button" 
              ng-disabled="verifyMobileForm.$invalid || verifyMobileForm.$pristine" 
              ng-click = "vm.checkMobile($event, document.getElementById('mobile').value)"
        >
            Next
        </md-button>
    </div>
</form>

这是我的控制器,我想将其设置为 true

(function ()
{
    'use strict';

    angular
        .module('app.pages.auth.verify-mobile')
        .controller('VerifyMobileController', VerifyMobileController);

    /** @ngInject */
    function VerifyMobileController($scope,dataservice,msApi, $state,$mdDialog)
    {
        var vm = this;
        vm.form = {};
        var getMob = dataservice.getData();
        if(getMob){
            vm.form.mobile = getMob[1].mobile;
            vm.verifyMobileForm.$invalid = true;
        }
    }
}();

你说你想在特定条件下启用按钮? 那么为什么不使用这样的东西

ng-disabled="(verifyMobileForm.$invalid || verifyMobileForm.$pristine) && DISABLEBUTTON"

...

并且在控制器中,您可以启用按钮,即使表单无效

$scope.DISABLEBUTTON = 假;