2016-03-02 45 views

回答

0
<div ng-app="myApp" ng-controller="MyCtrl"> 
    <div class="col-xs-12"> 
    <form name="myForm"> 
    <input type="text" ng-model="user.firstname"> 
     <input type="text" ng-model="user.secondname"> 
     <button type="button" ng-click="checkIsEmpty()" ng-disabled="!user">SUBMIT 
     </button> 
    </form> 
    </div> 
</div> 

編輯:

JS:

function MyCtrl($scope) { 
     $scope.user = {}; 

    $scope.checkIsEmpty = function(){ 
     return angular.equals({}, $scope.user); 
    } 
} 

小提琴:http://jsfiddle.net/nq1eyj1v/128/

+0

呀,只有當用戶obejct以前沒有定義的方法工作,但是,我要尋找的方法這將利用驗證器,而不是基於一個對象。 – uksz

+0

我沒有明白你的觀點。 – Ved

+0

你的答案不是通用的,只有在用戶沒有被定義之前工作。 – uksz

相關問題