2016-05-20 7 views
0

ich an einem Skript arbeite, wo ein modaler erst nach der Ausgabe von Python-Datei öffnet, sagt dup_yes 1offenen modale nur, wenn Daten wahr ist

Ich habe die modal, wie folgend:

<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#dupModal" data-keyboard="false" data-backdrop="static" ng-click="save_me()" >Save Me</button> 

<div class="modal fade" id="dupModal" role="dialog"> 
    <div class="modal-dialog"> 
     <!-- Modal content--> 
     <div class="modal-content"> 
      <div class="modal-header"> 
       <h3 class="modal-alert">Same name already exists</h3> 
       <h6 class="modal-ask">Save both entries or do you want to cancel?</h6> 
      </div> 
      <div class="modal-footer"> 
       <button type="button" class="btn btn-default" data-dismiss="modal" aria-hidden="true" >Keep Both</button> 
       <button type="button" class="btn btn-default" data-dismiss="modal" aria-hidden="true" >Close</button> 
      </div> 
     </div> 
    </div> 
</div> 

und mein Skript ist wie folgt:

$scope.save_me = function() { 
    http.get("path to python file").then(function(response){ 
     $scope.check=response.data; 
     if ($scope.check['login_status'] == 1){ 
      console.log("Mission is a Success\n"); 
      $scope.dup_yes=1; 
     } 
    }) 
} 

Wenn ich auf die Schaltfläche klicken, um es den Modal eröffnet und führt die python-Datei gleichzeitig.

Stattdessen will ich es nur das modale öffnen, wenn mein Python-Skript den Wert 1.

Irgendwelche Ideen auf, gibt, wie dies zu tun?

Antwort

2

Sie können auf die Modal von der Steuerung und öffnen Sie es wie folgt aus:

$scope.save_me = function() { 
    http.get("path to python file").then(function(response){ 
    $scope.check=response.data; 
     if ($scope.check['login_status'] == 1){ 
      console.log("Mission is a Success\n"); 
      $scope.dup_yes=1; 

      var modal = angular.element('#dupModal'); 
      //modal.modal('hide'); 
      modal.modal('show'); 

     } 
    }) 
    } 

Mayby eine bessere Lösung ist es, die modal-Aktion in einem separete Controller zu handhaben und dass in der aktuellen Controller injizieren die Verantwortlichkeit zu halten getrennt