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 ...
随机推荐
- 【Luogu】P1110报表统计(Splay)
题目链接 SBT,我居然没看出来. 就是插入的时候考虑向平衡树里插两个差值,删一个差值. 另一个操作就是维护某元素和其前驱后继的差值最小值就行了. 然后Splay超时了…… (貌似Splay超时了之后 ...
- 【CF1017C】The Phone Number(构造)
题意:要求构造一个1-n的排列,使得它的LIS+LDS最小 n<=1e5 思路:一个百度之星时候从LYY处听来的结论:1-n随机排列的LIS期望是根号级别的 考虑将LIS与LDS都构造成根号级别 ...
- TopCoder SRM596 DIV2 1000: SparseFactorialDiv2
题意: For an integer n, let F(n) = (n - 0^2) * (n - 1^2) * (n - 2^2) * (n - 3^2) * ... * (n - k^2), wh ...
- LeetCode OJ——Remove Duplicates from Sorted List
http://oj.leetcode.com/problems/remove-duplicates-from-sorted-list/ 链表的去重,要考虑链表的本质. #include <ios ...
- react状态
组件的生命周期分成三个状态: Mounting:已插入真实 DOM Updating:正在被重新渲染 Unmounting:已移出真实 DOM React 为每个状态都提供了两种处理函数,will 函 ...
- AC日记——[USACO15DEC]最大流Max Flow 洛谷 P3128
题目描述 Farmer John has installed a new system of pipes to transport milk between the stalls in his b ...
- (42)C#Stopwatch类(计算程序运行时间)
引入命名空间 using System.Diagnostics; static void Main(string[] args) { Stopwatch sw = new Stopwatch(); s ...
- (5)DataSet
DataTable赋值给DataSet DataSet ds = new DataSet(); DataTable dt1 = new DataTable(); DataTable dt2 = new ...
- 空扫描Idle Scanning
空扫描Idle Scanning 空扫描Idle Scanning是一种借助第三方实施的端口扫描技术,可以很好的隐蔽扫描主机本身.它的实现基于以下两个TCP工作机制. (1)在TCP三次握手阶 ...
- 在spring中使用数据库
若要在spring中使用数据库,首先需要配置数据源. 1.使用数据源连接池,可以使用DBCP(Data Base Connection Pooling) <bean id="datas ...