(function() {
'use strict'; angular.module('frontierApp')
.directive('confirmPopup', ['$timeout', ConfirmPopupDirective])
.directive('messageTips', ['$timeout', '$rootScope', MessageTipsDirective]); function ConfirmPopupDirective($timeout) {
var directive = {
restrict: 'A',
scope: {
confirmPopup: '&',
confirmTitle: '=',
confirmContent: '=',
},
link: link,
transclude: true,
template: '<div class="trans-clude" ng-transclude ng-click="show()"></div>' +
'<div class="modal fade confirm-modal">' +
'<div class="modal-dialog">' +
'<div class="modal-content">' +
'<div class="modal-header">' +
'<span class="close ES3iconfont ES3icon-icon-closs" ng-click="close()"></span>' +
'<h4 class="modal-title" ng-bind="confirmTitle"></h4>' +
'</div>' +
'<div class="modal-body"><i class="iconfont icon-warning"></i>' +
'<p ng-bind="confirmContent"></p>' +
'</div>' +
'<div class="modal-footer">' +
'<button class="button-cancel" ng-click="close()">取消</button>' +
'<button class="button-confirm" ng-click="confirm()">确定</button>' +
'</div>' +
'</div>' +
'</div>' +
'</div>'
}; return directive; function link(scope, element, attrs) { scope.show = function() {
element.find('.modal').modal();
}; scope.close = function() {
element.find('.modal').modal('hide');
}; scope.confirm = function() {
element.find('.modal').modal('hide');
$timeout(function() {
scope.confirmPopup();
}, 500);
};
}
} function MessageTipsDirective($timeout, $rootScope) { var directive = {
restrict: 'EA',
link: link,
replace: true,
template: '<div class="message-tips"></div>'
}; return directive; function link(scope, element, attrs) { //level: success,error
$rootScope.showMessage = function(title,message, level, delay) {
var tip = angular.element('<div class="alert message-tip" >\
<div class="message-tip-header">'+title+'\
<button type="button" class="close" data-dismiss="alert"><span aria-hidden="true">×</span></button>\
</div><div class="message-tip-body"><i class="iconfont icon-'+level+' iconSuccess"></i>' + message + '</div></div>').appendTo(element);
tip.addClass('alert-' + level); if (delay) {
$timeout(function() {
tip.alert('close');
}, delay * 1000);
} element[0].addEventListener('click',function(e){
if(e.target.nodeName === 'BUTTON'){
if(message == '请选择要恢复的数据源'){
// location =
}
}
}) };
}
} angular.element('body').append('<div message-tips></div>');
})();

  

angularjs 自定义指令弹窗的更多相关文章

  1. AngularJs自定义指令详解(1) - restrict

    下面所有例子都使用angular-1.3.16.下载地址:http://cdn.bootcss.com/angular.js/1.3.16/angular.min.js 既然AngularJs快要发布 ...

  2. AngularJS: 自定义指令与控制器数据交互

    <!doctype html> <html> <head> <meta charset="utf-8"> <title> ...

  3. 浅析AngularJS自定义指令之嵌入(transclude)

    AngularJS自定义指令的嵌入功能与vue的插槽十分类似,都可以实现一些自定义内容展现.在开始之前先简单介绍下自定义指令的transclude属性和AngularJS的内置指令ng-transcl ...

  4. angularjs自定义指令Directive

    今天学习angularjs自定义指令Directive.Directive是一个非常棒的功能.可以实现我们自义的的功能方法. 下面的例子是演示用户在文本框输入的帐号是否为管理员的帐号"Adm ...

  5. angularJs 自定义指令传值---父级与子级之间的通信

    angularJs自定义指令用法我忽略,之前有写过,这里只说一下父子级之间如何传值: 例如: 模块我定义为myApp,index.html定义 <my-html bol-val="bo ...

  6. AngularJs自定义指令详解(6) - controller、require

    在前面文章中提到一旦声明了require,则链接函数具有第四个参数:controller. 可见require和controller是配合使用的. 在自定义指令中使用controller,目的往往是要 ...

  7. angularJs自定义指令.directive==类似自定义标签

    创建自定义的指令 除了 AngularJS 内置的指令外,我们还可以创建自定义指令. 你可以使用 .directive 函数来添加自定义的指令. 要调用自定义指令,HTML 元素上需要添加自定义指令名 ...

  8. angularJS——自定义指令

    主要介绍指令定义的选项配置 //angular指令的定义,myDirective ,使用驼峰命名法 angular.module('myApp', []) .directive('myDirectiv ...

  9. AngularJS自定义指令(Directives)在IE8下的一个坑

    在项目中,由于要兼容到IE8,我使用1.2.8版本的angularJS.这个版本是支持自定义指令的.我打算使用自定义指令将顶部的header从其他页面分离.也就是实现在需要header的页面只用在&l ...

随机推荐

  1. tcpdump概述

    tcpdump是一个用于截取网络分组,并输出分组内容的工具.tcpdump凭借强大的功能和灵活的截取策略,使其成为类UNIX系统下用于网络分析和问题排查的首选工具. tcpdump提供了源代码,公开了 ...

  2. 洛谷P1569属牛的抗议 超级强力无敌弱化版

    P1569 [USACO11FEB]属牛的抗议Generic Cow Prote- 题目描述 约翰家的N头奶牛聚集在一起,排成一列,正在进行一项抗议活动.第i头奶牛的理智度 为Ai,Ai可能是负数.约 ...

  3. 【P3056】【USACO12NOV】笨牛Clumsy Cows

    P3056 [USACO12NOV]笨牛Clumsy Cows 题目描述 Bessie the cow is trying to type a balanced string of parenthes ...

  4. Laravel 使用 JWT 做 API 认证之tymon/jwt-auth 1.0.0-beta.1实践 - moell - SegmentFault

    安装 将"tymon/jwt-auth": "1.0.0-beta.1" 添加到 composer.json 中,执行 composer update Prov ...

  5. svn基本命令使用

    1.svn help:可以通过该命令查看svn的所有操作命令,包括命令的缩写 2.首先需要从svn库中checkout对应的项目: (1)svn项目路径为svn://192.168.1.1/mypro ...

  6. visual studio code 调试reactjs

    1.首先到visual studio code官网下载ide. 2.打开visual studio code,点击右侧菜单条的小图标 找到[Debugger for Chrome],并安装 3.打开c ...

  7. GDOI模拟4.11~4.13总结

    总体情况 省选前的第一场模拟,就连续三天垫底滚粗了. 三天下来,只做了第一天的签到题,然后再做了一些水题的暴力,还不得分. 三天分数:100/400+40/400+90/400=230/1200,得了 ...

  8. Direct2D 第4篇 渐变画刷

    原文:Direct2D 第4篇 渐变画刷 #include <windows.h> #include <d2d1.h> #include <d2d1helper.h> ...

  9. LintCode刷题笔记--Flip Bits

    Flip Bits: 标签:位运算 题目:Determine the number of bits required to flip if you want to convert integer n  ...

  10. 大数据技术之Zookeeper

    第1章 Zookeeper入门 1.1 概述 Zookeeper是一个开源的分布式的,为分布式应用提供协调服务的Apache项目. 1.2 特点 1.3 数据结构 1.4 应用场景 提供的服务包括:统 ...