所以这里是我遇到麻烦的条件,它就像我有父控制器和一个儿童控制器,它是一个模态控制器,我有一个方法在父控制器,我想从儿童模态控制器调用,我不知道我失踪但是这就是我所尝试的.
App.controller('MailFolderController',['$scope','$http','$timeout','$stateParams','$window','mails','$interval',function ($scope,$http,$timeout,$stateParams,$window,mails,$interval) { $scope.check = function(){ console.log("call parent ==========>") } App.controller('orderCancellationController','$modal',$modal) { $scope.open = function (mail) { var modalInstance = $modal.open({ templateUrl: '/orderCancellationBox.html',controller: ModalInstanceCtrl,resolve: { mail: function () { return mail; } } }); }; // Please note that $modalInstance represents a modal window (instance) dependency. // It is not the same as the $modal service used above. var ModalInstanceCtrl = function ($scope,$modalInstance,mail) { $scope.mail = mail; $scope.submit = function () { $scope.$parent.check(); $modalInstance.close('closed'); }; $scope.cancel = function () { $modalInstance.dismiss('cancel'); }; }; ModalInstanceCtrl.$inject = ["$scope","$modalInstance",'mail']; }]); }]);
https://angular-ui.github.io/bootstrap/#/modal
原文链接:https://www.f2er.com/angularjs/140895.htmlbootstrap中的模态有一个’scope’选项,
scope – a scope instance to be used for the modal’s content (actually the $modal service is going to create a child scope of a provided scope). Defaults to $rootScope
使用范围:$scope应该允许您使用父控制器中定义的方法
例:
$scope.open = function (mail) { var modalInstance = $modal.open({ templateUrl: '/orderCancellationBox.html',scope: $scope,resolve: { mail: function () { return mail; } } }); };