[英]How do you access a parent function from UI Bootstrap Modal?
I'm trying to use a UI Bootstrap modal, vs a regular Bootsrap modal. 我正在尝试使用UI Bootstrap模式,而不是常规的Bootsrap模式。 I have a $scope.DoIt = function() in the parent controller, but when I try to call it from the modal, nothing happens. 我在父控制器中有一个$ scope.DoIt = function(),但是当我尝试从模式中调用它时,什么也没发生。
What am I doing wrong? 我究竟做错了什么?
How do you access a function in the parent controller? 您如何访问父控制器中的功能?
Here is how I open the modal: 这是我打开模态的方法:
applyConfirm: function() {
if(self.showingExpenses !== true) {
self.showingExpenses = true;
var modalInstance = $modal.open({
animation: true,
templateUrl: 'applyConfirm.html',
controller: function($scope, $modalInstance, expenses, jobsService, job) { //'ModalInstanceCtrl',
angular.extend($scope, {
expenses: expenses,
job: job
});
$scope.close = function() {
//self.showingExpenses = false;
$modalInstance.close();
};
}
}
You can set the parent scope for the modal using the scope
configuration passed in to $uibModal.open
, eg 您可以使用传入$uibModal.open
的scope
配置为模态设置父范围。
$uibModal.open({
scope: $scope
// other properties, etc
})
Angular scope inheritance should then make the Dolt
method available 角作用域继承应使Dolt
方法可用
controller: function($scope, $uibModalInstance /*, etc */) {
$scope.Dolt(); // this will call the parent scope method
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.