javascriptangularjsmeteorangular-meteorangularjs-ng-disabled

How to disable upload button when there is no file selected in meteorjs?


I had tried slideForm.$invalid , but it's not working.Can you suggest the best way?

      <form name="slideForm">
          <div class="aboutFile">
             <input type="file" name="file" fileread="vm.file" class="form-control" ng-model="vm.file">
                <div class="create-component--perma-bg">
                  <i class="fa fa-plus-square-o" aria-hidden="true"></i>
                   <span ng-if="!vm.file.name">Add File </span>
                   <span ng-if="vm.file.name">{{vm.file.name}}</span>
                </div>
            <button type="button" class="btn btn-info bgChangeBtnInfo" ng-
               click="vm.upload(vm.file)" ng-disabled="slideForm.$invalid"> 
                 Upload</button>
          </div>
      </form>

Solution

  • I think You have to make it as required field like this

    <input type="file" name="file" fileread="vm.file" class="form-control" ng-model="vm.file" required>