angular2 bootstrap modal
----html-------
<div #ele
class="modal fade " style="z-index: 9999"
data-backdrop="false"
data-show="true" >
<div class="modal-dialog">
<div class="modal-content">
<div class=" modal-header ">
<button type="button" class="close" (click)="onClose()" aria-label="Close"><span aria-hidden="true"><i
class="fa fa-times"></i></span></button>
<h4 class="modal-title"><span [innerText]="header"></span></h4>
</div>
<div class="modal-body slimScrollDiv"> <ng-content></ng-content>
</div>
</div>
</div>
</div>
-------ts--------------
import {Component, ElementRef, EventEmitter, Input, OnInit, Output, ViewChild} from '@angular/core';
@Component({
selector: 'eve-modal',
templateUrl: 'eve-modal.component.html'
})
export class ModalComponent implements OnInit {
private _shown=false;
private _allowDrag=false;
@ViewChild("ele")
private ele:ElementRef;
@Input()
set allowDrag(val){
if(val===this._allowDrag){
return;
}
if(val){
$(this.ele.nativeElement).drags({handle: ".modal-header"});
}
}
@Input()
header:string;
@Input()
get shown(){
return this._shown;
}
set shown(val){
if(this._shown===val){
return
}
this._shown=val;
this.showModal(val);
this.shownChange.emit(val);
}
@Output()
shownChange:EventEmitter<boolean> =new EventEmitter();
constructor(private eleRef:ElementRef) {
this.eleRef.nativeElement.style["z-index"]=9999;
}
ngOnInit() {
}
onClose(){
this.shown=false;
}
showModal(val:boolean){
if(val){
$(this.ele.nativeElement).find(".modal-content").attr("style","")
}
$(this.ele.nativeElement).modal(val?"show":"hide");
}
}
-------jquery drag extends-----------------
(function ($) {
$.fn.drags = function (opt) {
opt = $.extend({
handle: "",
cursor: "move"
}, opt);
var $selected = this.find(".modal-content");
var $elements = (opt.handle === "") ? this : this.find(opt.handle);
$elements.css('cursor', opt.cursor).on("mousedown", function (e) {
var pos_y = $selected.offset().top - e.pageY,
pos_x = $selected.offset().left - e.pageX;
$(document).on("mousemove", function (e) {
$selected.offset({
top: e.pageY + pos_y,
left: e.pageX + pos_x
});
}).on("mouseup", function () {
$(this).off("mousemove"); // Unbind events from document
});
e.preventDefault(); // disable selection
});
return this;
};
})(jQuery);
angular2 bootstrap modal的更多相关文章
- Bootstrap Modal 垂直方向加滚动条
原文链接:http://blog.csdn.net/cyh1111/article/details/52960747 背景 使用Bootstrap Modal实现用户资料修改,由于用户信息过多,默认M ...
- Bootstrap modal垂直居中
Bootstrap modal垂直居中 在网上看到有Bootstrap2的Modal dialog垂直居中问题解决方法,这种方法自己试了一下,并不能完全居中,并且窗口的大小不一样的话,每次显示的m ...
- 对bootstrap modal的简单扩展封装
对bootstrap modal的简单扩展封装 参考自:http://www.muzilei.com/archives/677 注:原文不支持bootstrap新版本,并且居中等存在问题 此段时间 ...
- bootstrap插件学习-bootstrap.modal.js
bootstrap插件学习-bootstrap.modal.js 先从bootstrap.modal.js的结构看起. function($){ var Modal = function(){} // ...
- Bootstrap modal常用参数、方法和事件
Bootstrap modal(模态窗)常用参数.方法和事件: 参数: 名称 类型 默认值 描述 Backdrop Boolean或字符串“static” True True:有背景,点击modal外 ...
- bootstrap modal 监听滚动条事件
bootstrap modal 里面使用datetimepicker时间控件,滚动时,时间控件并不会隐藏,这是一个小bug,在组里改下,当滚动条滚动时,直接隐藏这个时间控件,$("#alar ...
- Bootstrap modal模态框关闭时,combobox input下拉框仍然保留在页面上
问题描述: 当点击模态框的关闭按钮时,下拉框中的内容没有消失,而是移动到了页面左上角 分析:这个问题的定位在于是用的哪种模态框,bootstrap和easyui都可以实现模态框,但是两个方法实现的模态 ...
- bootstrap modal与select2使用冲突解决
今天发现项目使用bootstrap modal 与 jquery select2 结合时发现select2不起作用,点击select框不显示选项,查阅资料后发现是因为modal层遮挡了select2的 ...
- bootstrap modal 垂直居中对齐
bootstrap modal 垂直居中对齐 文章参考 http://www.bubuko.com/infodetail-666582.html http://v3.bootcss.com/Jav ...
随机推荐
- Kafka设计解析(二十三)关于Kafka监控方案的讨论
转载自 huxihx,原文链接 关于Kafka监控方案的讨论 目前Kafka监控方案看似很多,然而并没有一个“大而全”的通用解决方案.各家框架也是各有千秋,以下是我了解到的一些内容: 一.Kafka ...
- lwip lwiperf 方法进行性能测试 4.5MB/S
硬件配置: STM32F407 + DP83848 + FreeRTOS V10.1.1 + LWIP 2.1.2 2018年12月5日14:31:24 1.先读取 PHY 寄存器 , 查看 自 ...
- 【H5】dropload (移动端下拉刷新,上拉加载)
插件概要地址:http://ximan.github.io/dropload/ 一般下载其中的demo2对照修改即可使用. 小吐槽.我在项目中用的时候,有个后端说ajax麻烦但是还是要做体现他很热爱工 ...
- BroadcastReceiver广播相关 - 转
BroadcastReceiver广播接收者用于接收系统或其他程序(包括自己程序)发送的广播. 一.注册广播 在android中,我们如果想接收到广播信息,必须自定义我们的广播接收者.要写一个类来继承 ...
- web网站的并发量级别
web网站的并发量级别 评价一个网站的“大小”,处于视角的不同,有很多种衡量的方法,类似文章数,页面数之类的数据非常明显,也没有什么可以争议的.但对于并发来说,争议非常之多,这里就从一个技术的角度开始 ...
- R实战 第六篇:数据变换(aggregate+dplyr)
数据分析的工作,80%的时间耗费在处理数据上,而数据处理的主要过程可以分为:分离-操作-结合(Split-Apply-Combine),也就是说,首先,把数据根据特定的字段分组,每个分组都是独立的:然 ...
- react脚手架改造(react/react-router/redux/eslint/karam/immutable/es6/webpack/Redux DevTools)
公司突然组织需要重新搭建一个基于node的论坛系统,前端采用react,上网找了一些脚手架,或多或少不能满足自己的需求,最终在基于YeoMan的react脚手架generator-react-webp ...
- Linux shell(5)
shell程序流程控制的三大结构: 1. 顺序结构 2.选择结构 3.循环结构 顺序结构的定义: 顺序结构的程序设计是最简单的一种结构,它的执行顺序自上而下,依次执行,因此,我们只要按照解决问题的思路 ...
- Git的简单操作
一.Git安装 windows下,可在在git官网下载(https://git-scm.com/downloads) 也有360提供的git(http://baoku.360.cn/soft/show ...
- Github相册博客搭建
前一段时间我看见一个问答,大概意思就是程序员都是怎么用自己的专业技能逗女朋友或表白的. 看了很多,有写定时关机脚本恶搞的,也有简单写个html展示的,其中最著名的就是几年前有个人写了个网页记录他们在一 ...