Angular之模态弹窗ui-bootstrap-modal及轻量级弹窗ngDialog
ui-bootstrap 中模态
官网 angular-ui-bootstrap 对于ui-bootstrap集成大量指令如折叠ui.bootstrap.accordion、时间插件ui.bootstrap.datepicker、接下来要说明的模态窗ui.bootstrap.modal等.....
疑问? angular-ui-bootstrap-1.3.2 引入时遇到问题:
Error: [$injector:unpr] Unknown provider: $templateRequestProvider <- $templateRequest <- $uibModal

解决 angular-1.5.5 问题得以解决

官网案列——模态效果

ui-bootstrap-modal在线编辑代码 请猛点击这里
ui-bootstrap-modal实现Demo[折叠]如下
<!DOCTYPE html>
<html ng-app="ui.bootstrap.demo">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>ui.bootstrap 模态窗</title>
<link rel="stylesheet" href="framework/bootstrap-3.0.0/css/bootstrap.min.css" />
<script type="text/javascript" src="framework/angular-1.5.5/angular.js"></script>
<script src="framework/angular-ui-bootstrap-1.3.2/ui-bootstrap-tpls.min.js"></script>
</head>
<body ng-controller="ModalDemoCtrl">
<div style="padding: 20px;">
<button type="button" class="btn btn-primary" ng-click="open()">Open me!</button>
<button type="button" class="btn btn-success" ng-click="open('lg')">Large modal</button>
<button type="button" class="btn btn-default" ng-click="open('sm')">Small modal</button>
<div ng-show="selected">Selection from a modal: {{ selected }}</div>
</div>
<script type="text/javascript">
var myModal = angular.module('ui.bootstrap.demo', ['ui.bootstrap']);
myModal.controller('ModalDemoCtrl', function ($scope, $uibModal, $log) {
$scope.items = ['item1', 'item2', 'item3'];
$scope.open = function (size) {
var modalInstance = $uibModal.open({
templateUrl: 'myModalContent.html',
controller: 'ModalInstanceCtrl', /*依赖控制器注入*/
backdrop: "static",
size: size,
resolve: { /*传递到模态窗口中的对象*/
items1: function () {
return $scope.items;
}
}
});
//模态实例---ModalDemoCtrl中的$scope
//接收点击ok参数
modalInstance.result.then(function (selectedItem) {
$scope.selected = selectedItem;
}, function () {
$log.info('Modal dismissed at: ' + new Date());
});
}; $scope.toggleAnimation = function () {
$scope.animationsEnabled = !$scope.animationsEnabled;
};
}); //$uibModalInstance是模态窗口的实例
myModal.controller('ModalInstanceCtrl', function ($scope, $uibModalInstance, items1) {
$scope.items = items1;
$scope.selected = {
item: $scope.items[0]
};
$scope.ok = function () {
//$scope.selected.item 值传到
$uibModalInstance.close($scope.selected.item);
};
$scope.cancel = function () {
$uibModalInstance.dismiss('cancel');
};
});
</script> <script type="text/ng-template" id="myModalContent.html">
<div class="modal-header">
<h3 class="modal-title">I'm a modal!</h3>
</div>
<div class="modal-body">
<ul>
<li ng-repeat="item in items">
<a href="#" ng-click="$event.preventDefault(); selected.item = item">{{ item }}</a>
</li>
</ul>
Selected: <b>{{ selected.item }}</b>
</div>
<div class="modal-footer">
<button class="btn btn-primary" type="button" ng-click="ok()">OK</button>
<button class="btn btn-warning" type="button" ng-click="cancel()">Cancel</button>
</div>
</script>
</body>
</html>
ngDialog 轻量级弹窗
官网 ng-dialog
<!DOCTYPE html>
<html lang="en" ng-app="indexApp">
<head>
<meta charset="UTF-8">
<title>Title</title>
<!--引入第三方样式库bootstrap.min.css-->
<link rel="stylesheet" href="framework/bootstrap-3.0.0/css/bootstrap.min.css" />
<link rel="stylesheet" href="framework/ngDialog-0.6.4/css/ngDialog.css">
<link rel="stylesheet" href="framework/ngDialog-0.6.4/css/ngDialog-theme-default.css"> <link rel="stylesheet" href="css/main.css" />
<!--引入js库anglarjs-->
<script type="text/javascript" src="framework/1.3.0.14/angular.js"></script>
<script type="text/javascript" src="framework/ngDialog-0.6.4/js/ngDialog.js"></script>
</head>
<body ng-controller="indexCtrl">
<button class="btn btn-primary" ng-click="clickToOpen()">弹窗</button>
<script>
var myModal = angular.module('indexApp',['ngDialog']);
myModal.controller('indexCtrl',function($scope,ngDialog, $http){ $http.get('cardInfo/cardInfo.json').success(function(data) {
$scope.cardInfo = data;
}); $scope.clickToOpen = function () {
ngDialog.open({
template: 'templateId.html',
className:'ngdialog-theme-default ngdialog-theme-plain',
scope: $scope,
width: '60%',
controller:function($scope){
$scope.show = function(){
$scope.closeThisDialog(); //关闭弹窗
}
}
});
};
})
</script> <script type="text/ng-template" id="templateId.html">
<div class="ui-dialog-title ">卡片详情信息</div>
<div class="ui-dialog-content">
<table class="table table-bordered table-hover">
<thead>
<tr>
<th>场所名称</th>
<th>门名称</th>
<th>员工姓名</th>
<th>员工电话</th>
<th>卡号</th>
<th>开卡日期</th>
<th>部门名称</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="cardInfos in cardInfo">
<td>{{cardInfos.place}}</td>
<td>{{cardInfos.doorName}}</td>
<td>{{cardInfos.name}}</td>
<td>{{cardInfos.phoneNumber}}</td>
<td>{{cardInfos.cardNumber}}</td>
<td>{{cardInfos.carDate | date: 'yyyy-MM-dd' }}</td>
<td>{{cardInfos.department}}</td>
</tr>
</tbody>
</table>
<button type="submit" class="btn btn-primary" ng-click="show()">保存</button>
<button type="button" class="btn btn-default" ng-click="closeThisDialog()">取消 </button>
</div>
</script>
</body>
</html>
Angular之模态弹窗ui-bootstrap-modal及轻量级弹窗ngDialog的更多相关文章
- bootstrap Modal或者 bootbox弹窗时,页面混动至顶部
		bootstrap使用Modal时,页面自动滚动至了最顶部, 调用bootbox时,也是如此 查了半天资料,最后参考下述帖子,解决问题 https://stackoverflow.com/questi ... 
- Angular -ui - BootStrap组件的解释以及使用
		关于UI BootStrap UI BootStrap 是angularUI团队用纯粹angularJS语法编写的Bootstrap组件. 1. 关于ng-router(angular-router. ... 
- Bootstrap modal模态框关闭时,combobox input下拉框仍然保留在页面上
		问题描述: 当点击模态框的关闭按钮时,下拉框中的内容没有消失,而是移动到了页面左上角 分析:这个问题的定位在于是用的哪种模态框,bootstrap和easyui都可以实现模态框,但是两个方法实现的模态 ... 
- 重置 Bootstrap modal 模态框数据
		利用 Bootstrap modal 模态框弹层添加或编辑数据,第二次弹出模态框时总是记住上一次的数据值,stackoverflow 上找到个比较好的方法,就是利用 jQuery 的 clone 方法 ... 
- 对bootstrap modal的简单扩展封装
		对bootstrap modal的简单扩展封装 参考自:http://www.muzilei.com/archives/677 注:原文不支持bootstrap新版本,并且居中等存在问题 此段时间 ... 
- Bootstrap modal.js 源码分析
		/* ======================================================================== * Bootstrap: modal.js v3 ... 
- iOS开发UI篇—Modal简单介绍
		iOS开发UI篇—Modal简单介绍 一.简单介绍 除了push之外,还有另外一种控制器的切换方式,那就是Modal 任何控制器都能通过Modal的形式展⽰出来 Modal的默认效果:新控制器从屏幕的 ... 
- Bootstrap modal常用参数、方法和事件
		Bootstrap modal(模态窗)常用参数.方法和事件: 参数: 名称 类型 默认值 描述 Backdrop Boolean或字符串“static” True True:有背景,点击modal外 ... 
- bootstrap modal 监听滚动条事件
		bootstrap modal 里面使用datetimepicker时间控件,滚动时,时间控件并不会隐藏,这是一个小bug,在组里改下,当滚动条滚动时,直接隐藏这个时间控件,$("#alar ... 
随机推荐
- vue 路由 及 跳转传递参数的总结
			博客地址:https://ainyi.com/4 vue-router vue-router 是Vue.js官方的路由插件,它和vue.js是深度集成的,适合用于构建单页面应用.vue的单页面应用是基 ... 
- SQL语句害死人
			最近在弄Android的SQLite,觉得其语法是在难搞~ 在这里把一些正确规范的实例贴出来,供参考 '; 
- [转]What is Blue Prism?
			本文转自:https://www.guru99.com/blue-prism-tutorial.html#5 What is Blue Prism? Blue Prism is a UK-based ... 
- “每日一道面试题”.Net中GC的运行机制
			GC 也就是垃圾回收,经常遇到的面试题,关于GC 感觉可以写一本书,我们要做的也就是简单理解,如果有意愿,可以深入研究 所谓的垃圾回收,也就是清理回收托管堆上不再被使用的对象内存,并且移动仍在被使用的 ... 
- Java_Collections工具类
			Collections 工具类 * Collection与Collections区别 Collection 接口,(大部分集合类的实现接口) Collections 工具类(针对列表) * Colle ... 
- js/es6 元素拖动
			元素事件:鼠标按下事件/鼠标移动事件/鼠标松开事件 元素样式:让元素脱离文档流,采用绝对定位的方式. 一.鼠标按下事件 当鼠标在元素上面按下时,保存元素的初始偏移量和鼠标按下时的坐标,然后在状态变量里 ... 
- bat 批处理获取时间语法格式
			bat 批处理获取时间语法格式 取年份:echo %date:~0,4% 取月份:echo %date:~5,2% 取日期:echo %date:~8,2% 取星期:echo %date:~10 ... 
- Jmeter自带录制功能
			版本更新迭代较快的情况下,通过自动化进行冒烟测试以判断版本准入,在无接口文档的情况下,如果进行自动化?Jmeter有一个自带的录制功能,可以通过录制,获取各个接口设计情况,下面介绍如何进行使用 1.打 ... 
- 数组去重(JS)
			数据类型: (栈类型) 原始值:boolen,num,string,null,undefined (堆类型) 引用值:object,array 首先重新定义一个type()函数, <script ... 
- (网页)jquery-qrcode.js生成二维码
			基础用法 <div id="qrcode"></div> <script type="text/javascript"> n ... 
