2016-08-05 9 views
0

Ich habe verwendet ng-CSV-Import, um eine CSS-Datei vom Desktop zu importieren, und ich habe Schaltfläche senden, die die CSV hochlädt. Meine Anforderungen, um die Übermittlungsschaltfläche zu deaktivieren, bis der Benutzer eine CSS-Datei auswählt. Danke im Voraus.Deaktivieren Sie die Schaltfläche auf CSV-Import in angular js

<ng-csv-import name="uploadCsv" content="MyCsv" 
       separator="csv.separator" 
       result="csv.results" 
       accept="csv.accept" required> 
</ng-csv-import> 
<div class="col-xs-12 col-sm-12"> 
    <button type="submit" class="btn-top btn-rectangle" ng-click="submit()">Submit</button> 
</div> 

Antwort

1

Sie könnten wie so ng-disabled auf der Schaltfläche verwenden:

<button type="submit" class="btn-top btn-rectangle" ng-click="submit()" ng-disabled="yourDisabledVariable">Submit</button> 

Dann achten Sie auf den ng-csv-Import Inhalt in Ihrem Controller

//Default is disabled 
$scope.yourDisabledVariable = true; 
// Watch for changes on $scope.MyCsv 
$scope.$watch('MyCsv', function(newVal,oldVal){ 
    // see if user uploaded a csv by looking at $scope.MyCsv 
    if(newVal){ 
     // Enable the button 
     $scope.yourDisabledVariable = false; 
    } 
}) 
+0

Dank. Es hat gut funktioniert. – Warrior

-1

Sie können dies versuchen.

$('input[type="submit"]').prop('disabled', true); 
    $('input[type="text"]').keyup(function() { 
     if($(this).val() != '') { 
      $('input[type="submit"]').prop('disabled', false); 
     } 
    }); 
Verwandte Themen