• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

angularJS模态框$modal实例代码

angularjs 搞代码 4年前 (2021-12-31) 63次浏览 已收录 0个评论

本篇文章主要介绍了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) { //依赖<strong style="color:transparent">来源gao@daima#com搞(%代@#码网</strong>于modalInstance //items为传过来的值 $scope.modalBack = function() { //执行模态框内部操作 } $scope.ok = function() { $modalInstance.close($scope.textid); //关闭并返回当前选项 }; $scope.cancel = function() { $modalInstance.dismiss('cancel'); // 退出不执行任何操作 } }]) 

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持gaodaima搞代码网

以上就是angularJS模态框$modal实例代码的详细内容,更多请关注gaodaima搞代码网其它相关文章!


搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:angularJS模态框$modal实例代码
喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址