Home  >  Q&A  >  body text

angular.js - Angular 像这种重复判断的表达式 有什么好的解决办法吗?~

巴扎黑巴扎黑2713 days ago538

reply all(2)I'll reply

  • phpcn_u1582

    phpcn_u15822017-05-15 17:14:13

    It won’t have much impact if you write it like this now. If your judgment expression is too long, you can consider writing it as a function and calling the function directly

    For example:

    $scope.someFun(){
        return $scope.submitted && $scope.form.$invalid;
    }
    
    
    ng-disabled="someFun()"

    reply
    0
  • PHP中文网

    PHP中文网2017-05-15 17:14:13

    getter defines a submitDisabled, and then performs rule determination internally.

    get submitDisabled() {
      return submitted && form.$invalid
    }

    reply
    0
  • Cancelreply