angularjs 简易模态框

angularjs 中的模态框一般使用插件angular-ui-bootstrap书写。

这里记录一种简易的模态框写法:

1.警告消息框alert:

原理:

在html页面放入模态框样式代码,然后在控制器里面写下控制代码。

代码:

HTML页面:(写在view页面的最后)

<div class="modals" ng-show="modalstext" ng-style="modleheightmax">
<div >
<p>{{modalstext}}</p>
<button ng-click="modalstext=false">确定</button>
</div>
</div>

css:

.modals{width: 100%;background: rgba(0,0,0,0.5);position:absolute;top:0;}
.modals>div{overflow:hidden;width: 400px;height: 250px;border:2px solid #fff;margin: auto auto;border-radius: 10px;
       background: url("../img/listback.png");background-size: 100% 100%;}
.modals>div>p{font-size: 20px;color: #fff;height: 78px;margin:55px 60px;word-break:break-all;overflow: hidden}
.modals>div>button{width: 150px;margin:0 auto;display: block;}

控制器:(写在控制器的最开始)

/*获取页面高度*/
$scope.heightmax = $window.innerHeight;
/*加载模态框高度*/
$scope.modleheightmax = {"height":$scope.heightmax-404+"px","padding-top":($scope.heightmax-200)/2+"px"};

弹出文本:(在之前写alert中的地方加入)

$scope.modalstext = "请输入验证码!";

2.确认消息框confirm

HTML页面:(写在view页面的最后)

<div class="modals" ng-show="modalsonoff" ng-style="modleheightmax">
<div >
<p>{{modalsonoff}}</p>
<div class="modalsonoff">
<button ng-click="modalson();modalsonoff=false;">确定</button>
<button ng-click="modalsonoff=false">取消</button>
</div> </div>
</div>

css:除了和警告消息框alert中共用的的css外还需加上下面的部分,用来控制按钮样式。

.modals>div>.modalsonoff{margin:0 auto;width: 324px;}
.modals>div>.modalsonoff>button{float: left;margin: 0 5px;width: 150px;}

控制器:(和警告消息框alert中相同)

弹出文本:(在之前写alert中的地方加入)

$scope.modalsonoff ="您确定提交答案么?";
$scope.modalson=function (){/*在此处写确定后的处理函数*/}

  

angularjs 简易模态框的更多相关文章

  1. angularJs解决模态框下echarts不显示问题

    例如:摸态框myModal.html,给它命名一个id,id='myModal'; myModal.html页面想画一个echarts图表 这里是angularJs已经封装好的echarts在html ...

  2. angularjs modal模态框----创建可拖动的指令

    //最近项目中需要将angular-ui-bootstrap中用到的弹出框,使之可拖动,由于源文件中没有实现,需要自己实现指令,以下即为该指令,亲测可以实现..directive('draggable ...

  3. angularjs 给封装的模态框元素传值,和实现兄弟传值

    本例实现封装的元素所放的位置不同,而选择不同的传值,这里举例封装了bootstrap模态框,以后也方便大家去直接使用.方法举例如下:首先主页调用css/js有: <link rel=" ...

  4. angularJS使用rootscope创建父域和子模态框通用的属性与函数

    1. 在声明创建controller指明引用$rootscope reviewInterfaceDo.controller('reviewInterfaceDo', function($scope, ...

  5. angularjs 弹出框 $modal

    angularjs 弹出框 $modal 标签: angularjs 2015-11-04 09:50 8664人阅读 评论(1) 收藏 举报  分类: Angularjs(3)  $modal只有一 ...

  6. angularjs 弹出框 $modal 参数(转)

    angularjs 弹出框 $modal   $modal只有一个方法:open,该方法的属性有: templateUrl:模态窗口的地址 template:用于显示html标签 scope:一个作用 ...

  7. angularjs 下拉框

    @{ Layout = null;} <!DOCTYPE html> <html><head> <meta name="viewport" ...

  8. angular $modal模态框

    <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...

  9. web前端基础之SCC(定位-z-index模态框)

    目录 一:定位(position) 1.relative(相对定位) 2.absolute(绝对定位) 3.fixed(固定) 二:相对定位 1.相对定位 2.实现相对定位 三:绝对定位 1.实现绝对 ...

随机推荐

  1. cylance做的机器学习相关材料汇总

    https://www.cylance.com/en_us/products/our-products/protect----threatzero.html 产品介绍 关键!!!! https://w ...

  2. ionic2常见问题——修改应用图标及添加启动画面(官方命令行工具自动生成)

    1.项目根目录->resources 分别存放应用图标及添加启动画面,替换成自己的图案既可. 2.这样在命令行中重新运行ionic resources ,就能看到应用图标和名字已经被替换了: 3 ...

  3. 【2018年全国多校算法寒假训练营练习比赛(第四场)- E】通知小弟(强连通缩点)

    题目链接:https://www.nowcoder.com/acm/contest/76/E 题目描述         在战争时期,A国派出了许多间谍到其他国家去收集情报.因为间谍需要隐秘自己的身份, ...

  4. springmvc的RESTful风格

    springmvc对RESTful得支持RESTful架构,就是目前最流行得一种互联网软件架构.它结构清晰.符合标准.易于理解.扩展方便,所以挣得到越来越多网站的采用. RESTful(即Repres ...

  5. 开源项目Universal Image Loader for Android 说明文档 (1) 简介

     When developing applications for Android, one often facesthe problem of displaying some graphical ...

  6. VC6工程因行尾格式无法转换到VS2015

    VC6工程因行尾格式无法转换到VS2015(金庆的专栏 2017.6)参考:https://connect.microsoft.com/VisualStudio/feedback/details/54 ...

  7. C++11中提供了std::bind

    再来看看std::bind C++11中提供了std::bind.bind()函数的意义就像它的函数名一样,是用来绑定函数调用的某些参数的. bind的思想实际上是一种延迟计算的思想,将可调用对象保存 ...

  8. 11.求二元查找树的镜像[MirrorOfBST]

    [题目] 输入一颗二元查找树,将该树转换为它的镜像,即在转换后的二元查找树中,左子树的结点都大于右子树的结点.用递归和循环两种方法完成树的镜像转换. 例如输入: 8    /  \  6      1 ...

  9. 【retina】手机上 1PX 边框

    1像素边框,在2倍屏幕上为2“占位”,3倍屏上为3“占位”,但设计师就要1“占位” .content h1:after, .content h2:after { border-top: 1px sol ...

  10. 【整理】石子合并问题(四边形不等式DP优化)

    有很多种算法: 1,任意两堆可以合并:贪心+单调队列. 2,相邻两堆可合并:区间DP    (O(n^3)) ). 3,相邻,四边形不等式优化DP (O(n^2) ). 4,相邻,GarsiaWach ...