<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<link rel="stylesheet" type="text/css" href="libs/bootstrap/dist/css/bootstrap.min.css"/>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.6.1/angular.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.6.1/angular-animate.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.6.1/angular-sanitize.js"></script>
<script src="//angular-ui.github.io/bootstrap/ui-bootstrap-tpls-2.5.0.js"></script>
</head>
<body ng-app='myapp' >
<h1 ng-controller='mycontroller' ng-click='kitme("lg")'>点我</h1>
<script type="text/ng-template" id="test.html"> //angular的模态框是可以载入一个html页面的,这里通过ng-template来创建一个html模块,也可以创建一个html文件。
<div class="modal-header">
<h3 class="modal-title" id="modal-title">hello</h3>
</div>
<div class="modal-body" id="modal-body">
<h1>就翻身解放了就</h1>
</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>
<script type="text/javascript">
angular.module('myapp',['ngAnimate', 'ngSanitize', 'ui.bootstrap']).controller('mycontroller',function ($scope,$uibModal){
$scope.item='item465554645';
$scope.kitme=function(size){
var modalInstance=$uibModal.open({
animation:true,
ariaLabelledBy: 'modal-title',
ariaDescribedBy: 'modal-body',
templateUrl: 'test.html', //载入的html文件
controller: 'ModalInstanceCtrl', //为载入的文件定义一个控制器
size: size, // size : lg sm 两值
resolve: { //resolve是成功创建模态框时,将有效数据传给模态框的控制器,模态框的控制通过注入的形式获取,这里传送了一个item的值;
item: function () {
return $scope.item;
}
}
});
modalInstance.result.then(function (selected) { //配合模态框模块执行完毕,成功关闭后执行的回调函数。selected是模态框传过来的值。
alert(selected);
}, function () {
alert('error');
},function (){
                        //取消关闭后执行。
                    });
};
});
angular.module('myapp').controller('ModalInstanceCtrl',function($uibModalInstance,$scope,item){ //此控制器只有在模态框成功打开时才会执行。
$scope.ok = function () {
$uibModalInstance.close('wang'); //close方法会将参数值回调返回。
}; $scope.cancel = function () {
$uibModalInstance.dismiss('cancel'); //关闭模态框,也会执行回调。
};
});
</script>
</body>
</html>

  

angular $modal模态框的更多相关文章

  1. 轻量级Modal模态框插件cta.js

    今天给大家分享一款轻量级Modal模态框插件cta.js.这是一款无需使用jQuery插件,纯js编写的模态框弹出特效.效果图如下: 在线预览   源码下载 实现的代码. html代码: <se ...

  2. 【bootstrap】modal模态框的几种打开方法+问题集锦

    第一部分: 关于bootstrap中modal的使用,下面把几种自己用的打开方法展示出来 首先呢,得有个Bootstrap的页面,这里就不说了. 其次呢,得有个modal放在页面中,不管你这段代码加在 ...

  3. 重置 Bootstrap modal 模态框数据

    利用 Bootstrap modal 模态框弹层添加或编辑数据,第二次弹出模态框时总是记住上一次的数据值,stackoverflow 上找到个比较好的方法,就是利用 jQuery 的 clone 方法 ...

  4. 修改bootstrap modal模态框的宽度

    原文链接:http://blog.csdn.net/wuhawang/article/details/52252912 修改模态框的宽度很简单,修改width属性就可以了 但是要注意的一点是,修改的不 ...

  5. 关于【bootstrap modal 模态框弹出瞬间消失的问题】

    前提是你没有重复引入bootstrap.js\bootstrap.min.js和modal.js.一下提供一个小例子. <button class="btnbtn-primary bt ...

  6. Bootstrap modal模态框关闭时,combobox input下拉框仍然保留在页面上

    问题描述: 当点击模态框的关闭按钮时,下拉框中的内容没有消失,而是移动到了页面左上角 分析:这个问题的定位在于是用的哪种模态框,bootstrap和easyui都可以实现模态框,但是两个方法实现的模态 ...

  7. bootstrap modal模态框的运用

    http://www.ziqiangxuetang.com/bootstrap/bootstrap-modal-plugin.html 方法 下面是一些可与 modal() 一起使用的有用的方法. 方 ...

  8. bootstrap下modal模态框中webuploader控件按钮异常(无法点击)问题解决办法【转】

    http://bbs.csdn.net/topics/391917552 具体如下:   $(function () {         var _$modal = $('#MyModal');    ...

  9. modal模态框插件

    用法: <!--模态框--> <div class="modal fade" id="myModal"> <div class=& ...

  10. amazeUI modal 模态框 关闭属性

    $('#my-prompt').modal({ relatedTarget: this, closeViaDimmer: false, // 点击外部空白处不关闭弹窗 closeOnConfirm:f ...

随机推荐

  1. Visual simultaneous localization and mapping: a survey 论文解析(全)

    当激光或声纳等距离传感器被用来构建小的静态环境的二维地图时,SLAM的问题被认为是解决的.然而,对于动态,复杂和大规模的环境,使用视觉作为唯一的外部传感器,SLAM是一个活跃的研究领域. 第一部分是简 ...

  2. rabbitmq 启动报错

    =============================================== 2017/10/24_第1次修改                       ccb_warlock = ...

  3. Qt编写QUI皮肤生成器

    用Qt写项目写多了,为了满足不同客户的需求,需要定制不同样式的界面,QUI皮肤生成器应运而生.思考这个工具的架构花了一年时间,如何从复杂的配色方案中提取出共性,然后将共性转为具体的QSS文件.思考架构 ...

  4. java推送数据到app--极光推送

    之前项目有用到需要把数据推送到app端 采用的是极光推送 特此把工具类和pom.xml需要的jar整理如下 pom.xml需要jar如下 <!-- 极光推送 --> <depende ...

  5. python csv模块的reader是一个迭代器,无法多次迭代

    在一个项目中,我需要多次遍历一个文本,该文本我是用csv.reader读取的.但后来发现,本文只对第一次循环有用,而之后的循环均为空白.经过排错后,我确定问题就出现在csv.reader()这一步.之 ...

  6. iPhone X 适配

    背景 iPhone X 刘海机于9月13日发布,给科技小春晚带来一波高潮.作为开发人员却多出来一份忧虑,iPhone X 怎么适配?我们 App 的脑袋会不会也长一刘海出来?Tabbar 会不会被圆角 ...

  7. ArcGis连接oracle失败:ORA-6413:连接未打开

    问题: 通过ARCMap 添加Oracle数据库连接时提示,ORA-6413:连接未打开. 运行环境: ArcGis 10.2 Oracle 10g 解决方法: 通过上网查找解决方法,网友说" ...

  8. (译)JToken的层次结构

     原文地址:https://stackoverflow.com/questions/38558844/jcontainer-jobject-jtoken-and-linq-confusion/3856 ...

  9. 关于“System.Data.OleDb.OleDbException,外部数据库驱动程序 (1) 中的意外错误。”的解决方案

    网站之前运行一直很正常,但有一次用户在导入格式为xls的excel文件,发生了错误,跟踪错误后抛出如下的异常: 错误提示: 未处理System.Data.OleDb.OleDbException HR ...

  10. centos7.4 搭建zabbix-server 3.4.5

    监控对服务器的重要性来说已经不需要我来一一赘述了,在众多的监控工具之中选择使用zabbix的原因是觉得它功能强大,可以引用的模板有很多,而且图形化做的草鸡棒. 废话就不多了,直接吃鸡. 本次搭建全部采 ...