angular 指令封装弹出框效果
就直接用bs的警告框啦~,Duang~
功能
可以设置message和type,type就是bs内置的几种颜色
默认提示3秒框自动关闭,或者点击x号关闭
代码
模板
<div class="alert alert-{{type || 'info'}}" ng-show="message">
<button type="button" class="close" ng-click="hideAlert()">
<span class="glyphicon glyphicon-remove"></span>
</button>
{{message}}
</div>
指令
/**
* 提示框
*/
commonToolDirectives.directive('alertBar',[function(){
return {
restrict: 'EA',
templateUrl: 'src/common/views/alertBar.html',
scope : {
message : "=",
type : "="
},
link: function(scope, element, attrs){
scope.hideAlert = function() {
scope.message = null;
scope.type = null;
};
}
};
}]);
服务
/**
* 提示框数据
*/
commonServices.factory('TipService', ['$timeout', function($timeout) {
return {
message : null,
type : null,
setMessage : function(msg,type){
this.message = msg;
this.type = type;
//提示框显示最多3秒消失
var _self = this;
$timeout(function(){
_self.clear();
},3000);
},
clear : function(){
this.message = null;
this.type = null;
}
};
}]);
用法
因为是全局提示,所以就只有一个,在
index.html中添加:<!--全局提示框-->
<alert-bar class="alert_bar" message="tipService.message" type="tipService.type"></alert-bar>同时保证他的
z-index最高然后因为需要在页面上直接访问tipService,需要在最外层
controller(如果没有可以直接绑定到$rootScope)中绑定://提示信息服务
$scope.tipService = TipService;调用的时候在c中直接设置message和type就可以了
TipService.setMessage('登录成功', 'success');当然从上面的模板代码可以看到,如果不传第二个参数,type默认是info,也就是那个蓝色的
效果
我的效果就是这样啦~
angular 指令封装弹出框效果的更多相关文章
- Javascript封装弹出框控件
1.首先先定义好弹出框的HTML结构 <div class="g-dialog-contianer"> <div class="dialog-windo ...
- JQuery+CSS3实现封装弹出登录框效果
原文:JQuery+CSS3实现封装弹出登录框效果 上次发了一篇使用Javascript来实现弹出层的效果,这次刚好用了JQuery来实现,所以顺便记录一下: 因为这次使用了Bootstrap来做一个 ...
- 代码录播:jQueryMobile 实现一个简单的弹出框效果
今天给大家带来的是 jQueryMobile 实现一个简单的弹出框效果,有兴趣的童鞋可以试试哦~ ^_^ 阅读原文:www.gbtags.com
- Bootboxjs快速制作Bootstrap的弹出框效果
Bootboxjs是一个简单的js库,简单快捷帮你制作一个Bootstrap的弹出框效果. 一.简介 bootbox.js是一个小的JavaScript库,它帮助您在使用bootstrap框架的时候快 ...
- jquery 弹出框效果
html <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <ti ...
- Android仿ios底部弹出框效果
准备: public class ActionSheet { public interface OnActionSheetSelected { void onClick(int whichButton ...
- bootstrap中popover.js(弹出框)使用总结+案例
bootstrap中popover.js(弹出框)使用总结+案例 *转载请注明出处: 作者:willingtolove: http://www.cnblogs.com/willingtolove/p/ ...
- 控制非模态弹出框(showModelessDialog)唯一且随父页面关闭
网站开发中,常常会遇到需要弹出窗体的情况,一般弹出框有模态和非模态两种,如下: 模态:window.showModalDialog() 非模态:window.showModelessDialog() ...
- 弹出框插件layer使用
layer是一款近年来备受青睐的web弹层组件,她具备全方位的解决方案,致力于服务各水平段的开发人员,您的页面会轻松地拥有丰富友好的操作体验. 插件官方地址:http://layer.layui.co ...
随机推荐
- [暑假集训--数位dp]hdu5898 odd-even number
For a number,if the length of continuous odd digits is even and the length of continuous even digits ...
- Java NIO系列教程(三-十二) Buffer
原文链接 作者:Jakob Jenkov 译者:airu 校对:丁一 Java NIO中的Buffer用于和NIO通道进行交互.如你所知,数据是从通道读入缓冲区,从缓冲区写入到 ...
- PHP中的验证码类(验证码功能设计之二)
运行结果: <!--vcode.class.php内容--> <?php class Vcode { private $width; //宽 private $height; //高 ...
- J2ME开发基本语法及小实例专题
原文发布时间为:2008-07-31 -- 来源于本人的百度文章 [由搬家工具导入] http://www.wcplym.com/sbjtClassArtl.asp?id=4 ·Canva专题:漂亮的 ...
- 写一简单kernel心得
当人按下笔记本开机键时.cpu的cs寄存器(基址)跟ip(偏移量)寄存器加电.被强制初始化为(jmp xxx:xxx) 跳转到bios所在的地址. 接着bios开机自检(这个不需要了解,只需了解最后跳 ...
- declaration specifier, declarator, type specifier
static struct abc * b; static struct abc : declaration specifier * b : declarator struct abc : type ...
- android 设置app root权限简单方法
vim frameworks/base/core/java/com/android/internal/os/ZygoteConnection.java +709 private static void ...
- Struts+ibatis-学习总结二
1封装json 在Action中以传统方式输出JSON数据 这一点跟传统的Servlet的处理方式基本上一模一样,代码如下 public void doAction() throws IOExcept ...
- js遍历map匹配数据和js遍历数组匹配map数据
var __LocalDataCities = { list: { "010": ["北京", "BEIJING"], "0100 ...
- MX
A mail exchanger record (MX record) is a type of resource record in the Domain Name System that spec ...