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 ...
随机推荐
- Python之路,Day4 - Python基础(转载Alex)
本节大纲 迭代器&生成器 装饰器 基本装饰器 多参数装饰器 递归 算法基础:二分查找.二维数组转换 正则表达式 常用模块学习 作业:计算器开发 实现加减乘除及拓号优先级解析 用户输入 1 - ...
- Django项目:CRM(客户关系管理系统)--14--06PerfectCRM实现King_admin注册功能获取内存优化处理
<th >{% get_app_name admin_class.model %}{{ admin_class }} </th> #kingadmin_tags.py # —— ...
- PHP的注释规范
<?php //注释规范 /** *函数的功能 *@param 参数类型 参数名1 参数解析 *@param 参数类型 参数名2 参数解析 *@return 返回值类型 返回值解析 *@auth ...
- LintCode刷题笔记-- InterLeaving
标签: 动态规划 解题思路 1. 这道题最重要的是,存在三个字符串,但是并不需要两个二维矩阵来进行解,因为可以使用i+j-1来代表s3的下标,这样就可以通过i和j来遍历s3了.因为对于任何一个合法的交 ...
- Web编译器Visual Studio扩展
原文地址:https://marketplace.visualstudio.com/items?itemName=MadsKristensen.WebCompiler 一个Visual Studio扩 ...
- 微服务Eureka使用详解
Eureka是spring cloud中的一个负责服务注册与发现的组件.遵循着CAP理论中的A(可用性)P(分区容错性). 一个Eureka中分为eureka server和eureka client ...
- SQL语句问题具体什么意思呢?
SQL语句问题 底下SQL查询语法中的 as A 和 as B 是什么意思?为什么A和B不用定义就能用? 程序代码: Private Sub LoadFileList(ByVal strSub ...
- $.extend用法详解(一)
jQuery.extend( target [, object1 ] [, objectN ] ) 在这里target是Object,它有两个作用: 1. 如果后面没有对应的object1及objec ...
- LeetCode169 Majority Element, LintCode47 Majority Number II, LeetCode229 Majority Element II, LintCode48 Majority Number III
LeetCode169. Majority Element Given an array of size n, find the majority element. The majority elem ...
- 编程语言分类及python所属类型
编程语言分类及python所属类型 编程语言主要从以下几个角度为进行分类:编译型和解释型.静态语言和动态语言.强类型定义语言和弱类型定义语言. 编译和解释的区别是什么? 编译器是把源程序的每一条语句都 ...