<script type="text/javascript" src="/assets/JS/plugins/jquery.min.js"></script>
<script type="text/javascript" src="/assets/JS/plugins/jquery-migrate.min.js"></script>
<script type="text/javascript" src="/assets/JS/AngularJS/angular.js"></script>
<script type="text/javascript" src="/assets/JS/AngularJS/i18n/angular-locale_zh.js"></script>
<!-- AngularJs+Bootstrap -->
<script src="/Assets/JS/plugins/angularjs/plugins/ui-bootstrap-tpls.min.js"></script>

1、加入jquery和angular的引用

2、加入ui-bootstrap-tpls.min.js,这个是bootstrap对angularjs的封装

3、编写对话框模板

<script type="text/ng-template" id="Service.html">
<div class="portlet box blue ">
<div class="portlet-title">
<div class="caption">
<i class="fa fa-gift"></i>服务协议
</div>
</div>
<div class="portlet-body">
<div class="scroll-body" slimscroll="{height : 500}" style='height:500px;'>
<strong style='text-align:center'>服务协议</strong><br />
</div>
<ul class="pager">
<li class="previous">
<a href="javascript:;" class="btn blue" ng-click='Refuse()'>
<i class="fa fa-angle-left"></i>拒绝 </a>
</li>
<li class="next">
<a href="javascript:;" class="btn blue" ng-click='Agree()'>同意 <i class="fa fa-angle-right"></i>
</a>
</li>
</ul> </div>
</div>
</script>

5、添加ng-click事件,如: <a href="javascript:;" ng-click="OpenDlg('lg')">《服务协议》</a> 

6、当然不要忘记了这个: var app = angular.module('appMain', ['ui.bootstrap']);

7、在控制器中处理打开对话框的点击事件

$scope.OpenDlg=function(size){
var size=size||'';//size是一个窗口大小的参数,可采用lg,sm,默认值空白,以此来控制窗口大小
var modalInstance = $modal.open({
templateUrl: 'Service.html', //模板url
controller: 'ctrlDlgService', //控制器
size : size,//默认窗口大小
resolve: { //参数传递
Agree : function() {
return [true, false]
}
}
});
modalInstance.opened.then(function(){
console.log('modal is opened'); //模态窗口打开之后执行的函数
});
modalInstance.result.then(function (result) {
$scope.selected = result;//窗口点击关闭后的返回值
console.log('result:'+result);
}, function (reason) {
console.log(reason);//点击空白区域,总会输出backdrop click,点击取消,则会触发cancel
$log.info('Modal dismissed at: ' + new Date());
});
}

8、对话框控制器

app.controller('ctrlDlgService', function ($scope, $http,$modal,growl,$modalInstance,Agree){
$scope.items = Agree;//获取参数
// 拒绝事件
$scope.Refuse = function() {
console.log('Refuse');
$modalInstance.close(false);
};
//同意事件
$scope.Agree = function() {
console.log('Agree');
$modalInstance.close(true);
};
//退出事件
$scope.cancel = function() {
$modalInstance.dismiss('cancel');
}
})

9、搞定收工

Bootstrap+AngularJS对话框实例的更多相关文章

  1. 前端开发利器: Bootstrap + AngularJS

    http://blog.csdn.net/conquer0715/article/details/51181391 概述 在HTML5盛行的互联网时代,涌现诸多的前端html/css/js框架,基于其 ...

  2. AngularJS:实例

    ylbtech-AngularJS:实例 1.返回顶部 1. AngularJS 实例 实例 您可以在线编辑实例,然后点击按钮查看结果. AngularJS 实例 <div ng-app=&qu ...

  3. 第一个AngularJS表达式实例

    <!DOCTYPE html><html><head><meta http-equiv="Content-Type" content=&q ...

  4. 详解Linux交互式shell脚本中创建对话框实例教程_linux服务器

    本教程我们通过实现来讲讲Linux交互式shell脚本中创建各种各样对话框,对话框在Linux中可以友好的提示操作者,感兴趣的朋友可以参考学习一下. 当你在终端环境下安装新的软件时,你可以经常看到信息 ...

  5. angularjs directive 实例 详解

    前面提到了angularjs的factory,service,provider,这个可以理解成php的model,这种model是不带html的,今天所说的directive,也可以理解成php的mo ...

  6. bootstrap + angularjs + seajs构建Web Form前端2

    bootstrap + angularjs + seajs构建Web Form前端(二) 回顾 上一篇讲解了引入bootstrap构建一个简单的登录页面,如何让angularjs自动启动并绑定视图,操 ...

  7. bootstrap + angularjs + seajs构建Web Form前端(1)

    bootstrap + angularjs + seajs构建Web Form前端(一) 简介 Bootstrap是Twitter推出的一个用于前端开发的开源工具包,它由Twitter的设计师Mark ...

  8. Bootstrap 模态对话框只加载一次 remote 数据的解决办法 转载

    http://my.oschina.net/qczhang/blog/190215 摘要 前端框架 Bootstrap 的模态对话框,可以使用 remote 选项指定一个 URL,这样对话框在第一次弹 ...

  9. bootstrap模态对话框

    bootstrap模态对话框 前提是引入bootstrap的css和js的东西 data-backdrop="static"代表的是点击旁边的内容,不进行关闭操作,但是esc的时候 ...

随机推荐

  1. java重载和重载的区别

    重载 public class A{     public void test(){}     public void test(int num){}     public void test(Str ...

  2. 44(function pointer 2)

    #include<iostream> using namespace std; class A { public: int x; int sayhello() { cout<< ...

  3. Python面试数据库

    1.列举常见的关系型数据库和非关系型都有那些? 关系型 : MySQL,SQL Server ,Oracle , Sybase, DB2 非关系型 : Redis, MongodDB 2.MySQL常 ...

  4. sql中select into和insert into的区别

    select into主要是作用于没有新建表,在复制数据的时候新建 insert into主要作用于已经新建了一个表,直接把要复制的数据复制到新建好的表中

  5. Bitfinex API

    本文介绍Bitfinex APi Platform Status Get the current status of the platform. Maintenance periods last fo ...

  6. 2018/03/09 每日一个Linux命令 之 chgrp/chown

    每日一个Linux命令 2018-03-09 Linux 命令 chgrp/chown chgrp [-参数] [文件或者目录] chown [-参数] [文件所有者]:[文件所属群组] [文件或者目 ...

  7. flask_SQLAlchemy常用数据类型及列选项

    SQLAlchemy常用数据类型:1. Integer:整形,映射到数据库中是int类型.2. Float:浮点类型,映射到数据库中是float类型.他占据的32位.3. Double:双精度浮点类型 ...

  8. 图片放大_css3

    .flash_little_img{position:relative;}.flash_little_img{width:500px;height:333px;border:none; margin: ...

  9. mysql python pymysql模块 增删改查 查询 fetchmany fetchall函数

    查询的fetchmany fetchall函数 import pymysql mysql_host = '192.168.0.106' port = 3306 mysql_user = 'root' ...

  10. vue-页面回退

    <template> <div> <button @click="goback">我是Home01</button> </di ...