angular模态框位置_angularJS模态框$modal

1.引入$modal模块

如:angular.module('ModalCtrl',['$modal' ,'$scope' , function($modal ,$scope ){ }]);

2.执行调模态框 函数

$scope.editModule = function(type, size, id) {

$scope.id = id;

var modalInstance = $modal.open({

templateUrl: 'tpl/weichat_modulebaseinfo.html', //template:'html元素模板',

controller: 'EditModuleCtrl', // 初始化模态范围

size: size, //大小配置

scope: '一个作用域为模态的内容使用($modal会创建一个当前作用域的子作用域,scope可有可无)默认为$rootScope',

resolve: {

items: function() {

return $scope.id; //向模态框控制器中传值

}

}

background: '', //控制背景,true(有) or false(无),static背景存在,但是点击模态窗口之外,模态窗不关闭

keyboard: '', //按下Esc时,模态对话框是否关闭,默认为ture

windowClass: '' //指定一个class并被添加到模态窗口中

});

modalInstance.result.then(function(selectedItem) { //模态框关闭后返回函数,selectedItem为返回值

})

}

3.创建模态框控制器

app.controller('EditModuleCtrl', ['$scope', '$modalInstance', 'BookService', '$stateParams', 'items', function($scope, $modalInstance, BookService, $stateParams, items) { //依赖于modalInstance

//items为传过来的值

$scope.modalBack = function() {

//执行模态框内部操作

}

$scope.ok = function() {

$modalInstance.close($scope.textid); //关闭并返回当前选项

};

$scope.cancel = function() {

$modalInstance.dismiss('cancel'); // 退出不执行任何操作

}

}])

//模态框完成

本文来源于网络:查看 >https://blog.csdn.net/Drongguang/article/details/52947016

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值