我正在编写一个脚本,只有在python文件的输出显示dup_yes为1后才会打开模态
我的模态如下:
<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>
我的脚本如下:
$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;
}
})
}
当我点击按钮时,它会打开模态并同时运行python文件。
相反,我希望它只在我的python脚本给出值1时打开模态。
关于如何做到这一点的任何想法?
答案 0 :(得分:2)
您可以从控制器访问模态并将其打开,如下所示:
$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更好的解决方案是在separete控制器中处理模态操作并将其注入当前控制器以将责任分开