2016-08-05 3 views
0

ng-csv-importを使用してデスクトップからCSSファイルをインポートしました.CSSVをアップロードする送信ボタンがあります。ユーザーがCSSファイルを選択するまで、送信ボタンを無効にする私の要件。前もって感謝します。角度jsのcsvインポートでボタンを無効にする

<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> 

答えて

1

あなたはそうのようなボタンをNG-無効に使用することができます

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

は、その後、あなたのコントローラでNG-CSVインポートコンテンツ

//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

感謝を監視します。それは正常に働いた。 – Warrior

-1

これを試すことができます。

$('input[type="submit"]').prop('disabled', true); 
    $('input[type="text"]').keyup(function() { 
     if($(this).val() != '') { 
      $('input[type="submit"]').prop('disabled', false); 
     } 
    }); 
関連する問題