我想将数据从控制器传递到离子模态,但我没有找到任何方法来做到这一点。所以请提出建议
what i have tried:-
var modalInstance = $modal.open({
templateUrl: 'confirm_booking.html',
controller: 'confirm_bookCtl',
resolve: {
items: function () {
return $scope.items;
}
}
});
but $modal is undefined in controller
答案 0 :(得分:0)
//首先,您不需要声明控制器,因为您可以从控制器中调用模态
.controller('MyController', function($scope, $ionicModal) {
$ionicModal.fromTemplateUrl('templates/modal-template.html', {
scope: $scope,
animation: 'slide-in-up',
}).then(function(modal) {
$scope.modal = modal;
});
$scope.openModal = function() {
$scope.modal.show();
};
$scope.closeModal = function() {
$scope.modal.hide();
};
//Cleanup the modal when we're done with it!
$scope.$on('$destroy', function() {
$scope.modal.remove();
});
// Execute action on hide modal
$scope.$on('modal.hidden', function() {
// Execute action
});
// Execute action on remove modal
$scope.$on('modal.removed', function() {
// Execute action
});
});
也许您可以访问此页面