Reputation: 1254
I am working on a script where a modal opens up only after the output from python file says dup_yes is 1
I have the modal as following:
<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>
and my script is as follows:
$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;
}
})
}
When I click on button it opens up the modal and runs the python file simultaneously.
Instead I want it to open up the modal only when my python script gives the value 1.
Any ideas on how to do this?
Upvotes: 0
Views: 352
Reputation: 16856
You can access the modal from the controller and open it like this:
$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 a better solution is to handle the modal action in a separete controller and inject that into your current controller to keep the responsibilities separate
Upvotes: 2