我已经看到这类问题,并找到了一些好的线索,但是它们在我的环境中都不起作用,所以我想知道是否还有更通用的方法。我有一个分配了ID的模式:
<div id="sandbox" class="modal-header modal-header-interaction" ng-init="init()">
对控制器的ng-init调用很好,所以我只能在此处设置侦听器,但是我无法确定正确的语法。到目前为止,我已经尝试过:
$( "#sandbox" ).on('shown', function(){
alert("Shown!");
});
此:
$('#sandbox').hasClass('in', function(){
alert("Shown!");
});
此:
$(window).on("shown", function(e) {
$('#sandbox').modal('show');
alert('OK');
});
...我感觉我离这里很近,有人对我可能要去的地方有个看法吗?
编辑
更多信息:
这些模态是在以下工厂中创建的:
var dialogOptions = {
templateUrl: 'views/sandbox/template/custom-plan/custom-sandbox-model-window.html',
controller: 'customPlanDataCtrl'
}
电话是:
ModalDialogFactory.showDialog(dialogOptions);
模式对话框工厂返回以下内容:
return {
showDialog: function (modalOptions) {
var modalConfig = {};
angular.extend(modalConfig, modalDialogDefaults, modalOptions);
modalInstance = $modal.open(modalConfig);
modalInstance.rendered.then(() => {
alert('OK');
});
return modalInstance.result;
}
}
答案 0 :(得分:0)
创建自己的触发器
with open("./data.txt") as read_file: # The file being read
with open("./Phone Numbers.txt", 'w') as write_file: # New file being created
for data in read_file:
for d in data.strip("\n").split(','):
if "Phone number" in d:
write_file.write(d[16:].strip(" ") + "\n")
答案 1 :(得分:0)
正如我在评论中提到的,我强烈建议使用本机AngularJS实现,例如UI Bootstrap提供的实现。这是模态($uibModal
)的非常简单的实现,显示了在打开,呈现和关闭/关闭模态时如何采取特定的动作。
angular.module('app', ['ui.bootstrap'])
.controller('ctrl', ($scope, $uibModal) => {
$scope.showModal = () => {
console.log('showing modal...');
var modalOptions = {
backdrop: 'static',
templateUrl: 'modalSample.html',
controller: ($scope, $uibModalInstance) => {
$scope.Ok = () => $uibModalInstance.close('can use any primitive or object here');
}
};
var modal = $uibModal.open(modalOptions);
debugger;
modal.opened.then(() => {
console.log('modal opened');
});
modal.rendered.then(() => {
console.log('modal rendered');
});
modal.result.then((data) => {
console.log('modal closed with response: ' + data);
})
.catch(() => {
console.log('modal dismissed');
});
};
})
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.7.2/angular.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular-ui-bootstrap/2.5.0/ui-bootstrap-tpls.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css">
<div ng-app="app" ng-controller="ctrl" style="padding: 20px;">
<button class="btn btn-primary" ng-click="showModal()">Show Modal</button>
<script type="text/ng-template" id="modalSample.html">
<div class="modal-header">
<h3 class="modal-title">Modal Sample</h3>
</div>
<div class="modal-body">
Here is the body of the modal. Press [Esc] to dismiss this modal or close it using the button to observe the difference between closing and dimissing.
</div>
<div class="modal-footer">
<button class="btn btn-default" ng-click="Ok()">OK</button>
</div>
</script>
</div>