angularjs 自定义指令弹窗
(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 自定义指令弹窗的更多相关文章
- AngularJs自定义指令详解(1) - restrict
下面所有例子都使用angular-1.3.16.下载地址:http://cdn.bootcss.com/angular.js/1.3.16/angular.min.js 既然AngularJs快要发布 ...
- AngularJS: 自定义指令与控制器数据交互
<!doctype html> <html> <head> <meta charset="utf-8"> <title> ...
- 浅析AngularJS自定义指令之嵌入(transclude)
AngularJS自定义指令的嵌入功能与vue的插槽十分类似,都可以实现一些自定义内容展现.在开始之前先简单介绍下自定义指令的transclude属性和AngularJS的内置指令ng-transcl ...
- angularjs自定义指令Directive
今天学习angularjs自定义指令Directive.Directive是一个非常棒的功能.可以实现我们自义的的功能方法. 下面的例子是演示用户在文本框输入的帐号是否为管理员的帐号"Adm ...
- angularJs 自定义指令传值---父级与子级之间的通信
angularJs自定义指令用法我忽略,之前有写过,这里只说一下父子级之间如何传值: 例如: 模块我定义为myApp,index.html定义 <my-html bol-val="bo ...
- AngularJs自定义指令详解(6) - controller、require
在前面文章中提到一旦声明了require,则链接函数具有第四个参数:controller. 可见require和controller是配合使用的. 在自定义指令中使用controller,目的往往是要 ...
- angularJs自定义指令.directive==类似自定义标签
创建自定义的指令 除了 AngularJS 内置的指令外,我们还可以创建自定义指令. 你可以使用 .directive 函数来添加自定义的指令. 要调用自定义指令,HTML 元素上需要添加自定义指令名 ...
- angularJS——自定义指令
主要介绍指令定义的选项配置 //angular指令的定义,myDirective ,使用驼峰命名法 angular.module('myApp', []) .directive('myDirectiv ...
- AngularJS自定义指令(Directives)在IE8下的一个坑
在项目中,由于要兼容到IE8,我使用1.2.8版本的angularJS.这个版本是支持自定义指令的.我打算使用自定义指令将顶部的header从其他页面分离.也就是实现在需要header的页面只用在&l ...
随机推荐
- 【并查集模板】 【洛谷P2978】 【USACO10JAN】下午茶时间
P2978 [USACO10JAN]下午茶时间Tea Time 题目描述 N (1 <= N <= 1000) cows, conveniently numbered 1..N all a ...
- bzoj 3895 取石子——博弈论
题目:https://www.lydsy.com/JudgeOnline/problem.php?id=3895 看题解:https://blog.csdn.net/popoqqq/article/d ...
- mac 下的 homebrew
如果安装了macport 就不能安装homebrew ,必须先卸载macport $ sudo port -f uninstall installed$ sudo rm -rf \/opt/local ...
- 推荐一个 Laravel admin 后台管理插件
如何优雅的写代码,我想是每位程序员的心声.自从15年初第一次接触 Laravel 4.2 开始,我就迷上使用 Laravel 框架了.我一直都想找个时间好好写写有关 Laravel 的使用文章,由浅入 ...
- arcgis人口专题图
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title> ...
- C++ 实现十大排序算法
教你手撕排序,这里有一个概念就是稳定排序.假定在待排序的记录序列中,存在多个具有相同的关键字的记录,若经过排序,这些记录的相对次序保持不变,即在原序列中,r[i]=r[j],且r[i]在r[j]之前, ...
- vue中 表头 th 合并单元格,且表格列数不定的动态渲染方法
吐槽 今天,在vue中遇到 复杂表格的渲染 ,需要合并表头th的单元格,且合并单元格的那列的表头数据是动态数据,也就是不知道会有多少个表头列,而这几个表头列还分了好几个子表头. 这个需求在js里用Ju ...
- 【如花美眷】初探weex
我想我更喜欢weex的原因,应该是weex可以直接运行在浏览器中,而不是像react-native需要运行在模拟设备中. 我想这个原因足以让我使用vue而不是RN. 初探就是稍微运行一下,来看步骤 可 ...
- tar解压.tar.bz2文件失败:tar: Error is not recoverable: exiting now
使用tar解压.tar.bz2文件: tar -jxvf xxxx.tar.bz2 报如下错误: 原因:未安装bzip yum -y install bzip2
- vue-cli3 关闭eslint
关闭eslint 直接注释掉package.json文件中eslint的配置就可以了(以下是vue-cli的默认配置) "eslintConfig": { "root&q ...