您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

关于angularJS模态框$modal的示例代码分享

2024/6/11 11:41:19发布44次查看
本篇文章主要介绍了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'); // 退出不执行任何操作 } }])
以上就是关于angularjs模态框$modal的示例代码分享的详细内容。
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product