----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的更多相关文章

  1. Bootstrap Modal 垂直方向加滚动条

    原文链接:http://blog.csdn.net/cyh1111/article/details/52960747 背景 使用Bootstrap Modal实现用户资料修改,由于用户信息过多,默认M ...

  2. Bootstrap modal垂直居中

    Bootstrap modal垂直居中   在网上看到有Bootstrap2的Modal dialog垂直居中问题解决方法,这种方法自己试了一下,并不能完全居中,并且窗口的大小不一样的话,每次显示的m ...

  3. 对bootstrap modal的简单扩展封装

    对bootstrap modal的简单扩展封装 参考自:http://www.muzilei.com/archives/677   注:原文不支持bootstrap新版本,并且居中等存在问题 此段时间 ...

  4. bootstrap插件学习-bootstrap.modal.js

    bootstrap插件学习-bootstrap.modal.js 先从bootstrap.modal.js的结构看起. function($){ var Modal = function(){} // ...

  5. Bootstrap modal常用参数、方法和事件

    Bootstrap modal(模态窗)常用参数.方法和事件: 参数: 名称 类型 默认值 描述 Backdrop Boolean或字符串“static” True True:有背景,点击modal外 ...

  6. bootstrap modal 监听滚动条事件

    bootstrap modal 里面使用datetimepicker时间控件,滚动时,时间控件并不会隐藏,这是一个小bug,在组里改下,当滚动条滚动时,直接隐藏这个时间控件,$("#alar ...

  7. Bootstrap modal模态框关闭时,combobox input下拉框仍然保留在页面上

    问题描述: 当点击模态框的关闭按钮时,下拉框中的内容没有消失,而是移动到了页面左上角 分析:这个问题的定位在于是用的哪种模态框,bootstrap和easyui都可以实现模态框,但是两个方法实现的模态 ...

  8. bootstrap modal与select2使用冲突解决

    今天发现项目使用bootstrap modal 与 jquery select2 结合时发现select2不起作用,点击select框不显示选项,查阅资料后发现是因为modal层遮挡了select2的 ...

  9. bootstrap modal 垂直居中对齐

    bootstrap modal 垂直居中对齐   文章参考 http://www.bubuko.com/infodetail-666582.html http://v3.bootcss.com/Jav ...

随机推荐

  1. unset MAILCHECK

    文件/etc/profile尾部有: unset MAILCHECK 为了解决:每次登陆linux总是提示:you hava a new mail

  2. Mysql千万级数据删除实操-企业案例

    某天,在生产环节中,发现一个定时任务表,由于每次服务区查询这个表就会造成慢查询,给mysql服务器带来不少压力,经过分析,该表中绝对部分数据是垃圾数据 需要删除,约1050万行,由于缺乏处理大数据的额 ...

  3. IDEA导包(以junit为例)

    ## IDEA导包(以junit为例) 1. 准备junit的jar包: * hamcrest-core-1.3.jar * junit-4.12.jar 2. 在项目中新建文件夹:lib 3. 将j ...

  4. less初识

    一种 动态 样式 语言. LESS 将 CSS 赋予了动态语言的特性,如 变量, 继承,运算, 函数. LESS 既可以在 客户端 上运行 (支持IE 6+, Webkit, Firefox),也可以 ...

  5. 关于Android开发环境的演变

    是不是我天生就不适合安装软件——经过eclipse.jdk.Android Studio的历次安装,我发觉自己似乎永远都装不好.去年eclipse断断续续装了三四天,那时希望能附加C++的软件包,却始 ...

  6. 【chrome】"您的连接不是私密连接" 解决办法

    1.启用显示证书选项 在Chrome的地址栏中输入:chrome://flags/#show-cert-link,选择"启用",重启Chrome浏览器.  (操作过无用) 2.安装 ...

  7. scala-数组操作

    package com.bigdata import scala.collection.mutable.ArrayBuffer object ArrayO { def main(args: Array ...

  8. [Oracle]坏块处理:确认坏块的对象

    如果已经知道 FILE#,BLOCK#,则 可以通过如下查询来看: SQL> SELECT SEGMENT_TYPE,OWNER||'.'||SEGMENT_NAME FROM DBA_EXTE ...

  9. MiZ702学习笔记8——让MiZ702变身PC的方法

    首先你需要一个安装好的linux系统,这里我用的是Ubuntu的虚拟机.VMWare的话,选择较高版本的成功率会高些(当然根据自己电脑的配置进行选择). 打开Ubuntu的虚拟机,找到一个叫做Disk ...

  10. selenium常用命令

    openopen(url)- 在浏览器中打开URL,可以接受相对和绝对路径两种形式type type(inputLocator, value)- 模拟人手的输入过程,往指定的input中输入值- 也适 ...