Angular2.0實(shí)現(xiàn)modal對(duì)話框的方法示例
本文實(shí)例講述了Angular2.0實(shí)現(xiàn)modal對(duì)話框的方法。分享給大家供大家參考,具體如下:
覺得寫的比較巧妙的就是樣式的選取~記錄下
CSS部分
.font {
font-family: "Microsoft YaHei", Arial;
font-size: 12px;
color: #333333;
}
.ky-modal-content {
min-width: 520px;
min-height: 240px;
}
.ky-modal-header {
/*height : 40px;*/
padding: 0 10px 0 10px;
}
.ky-modal-title {
font-size: 16px;
font-weight: 100;
}
.ky-modal-body {
min-height: 110px;
text-align: center;
}
.ky-modal-footer {
height: 30px;
border-top: 0;
text-align: -webkit-center;
}
.ky-modal-message {
padding-left: 3px;
vertical-align: middle;
}
.ky-modal-icon {
font-size: 16px;
vertical-align: middle;
}
.ky-modal-question-icon {
color:#ff8000;
}
.ky-modal-check-icon {
color:green;
}
.ky-modal-exclamation-icon {
color:red;
}
.ky-modal-close {
outline: none;
font-size: 30px;
margin-top: 8px;
font-weight: 100;
vertical-align: -webkit-baseline-middle;
}
.vertical-align-center {
display: flex;
display: -webkit-box;
display: -moz-box;
-webkit-box-align: center;
-moz-box-align: center;
text-align: -webkit-center;
}
HTML部分
<div [id]="id" class="modal fade" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content ky-modal-content">
<div class="modal-header ky-modal-header">
<button type="button" class="close ky-modal-close" data-dismiss="modal" aria-label="Close">
<span style="position: fixed;right: 10px;top:-6px" aria-hidden="true">×</span>
</button>
<h4 class="modal-title ky-modal-title" >{{title}}</h4>
</div>
<div class="modal-body ky-modal-body vertical-align-center">
<div>
<span style="font-size:18px;"> <span style="color:#ff0000;"><i class="fa ky-modal-icon" [ngClass]="iconClass" aria-hidden="true"></i></span></span>
<span class="ky-modal-message">{{message}}</span>
</div>
</div>
<div class="modal-footer ky-modal-footer">
<ky-button [type]="conformButtonType" data-dismiss="modal" (click)="confirmButtonDown()">{{confirmText}}</ky-button>
<ky-button [type]="'cancel'" data-dismiss="modal" (click)="cancelButtonDown()">{{cancelText}}</ky-button>
</div>
</div>
</div>
</div>
JS部分
import { Component, Input, Output, EventEmitter, OnInit } from '@angular/core';
@Component({
moduleId: module.id,
selector: 'ky-modal',
styleUrls: ['./ky-modal.css'],
templateUrl: './ky-modal.component.html',
})
export class KyModalComponent implements OnInit {
@Input() title:string = '';
@Input() type:string = '';
@Input() message:string = '';
@Input() confirmText:string = '';
@Input() cancelText:string = '';
@Input() id:string;
@Input() conformButtonType:string;
iconType ='question';
iconClass :any = {'fa-question-circle':false,
'fa-check-circle':false,
'fa-exclamation-circle':false};
typeList = ['question', 'check', 'exclamation'];
@Output() actionButtonDown = new EventEmitter();
@Output() undoButtonDown = new EventEmitter();
cancelButtonDown() {
this.undoButtonDown.emit('event');
}
confirmButtonDown() {
this.actionButtonDown.emit('event');
}
determine() {
let that = this;
if(that.type && _.contains(that.typeList,that.type)) {
that.iconType = that.type;
}
that.iconClass[`fa-${that.iconType}-circle`] = true;
that.iconClass[`ky-modal-${that.iconType}-icon`] = true;</span>
}
ngOnInit() {
this.determine();
}
}
更多關(guān)于AngularJS相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《AngularJS指令操作技巧總結(jié)》、《AngularJS入門與進(jìn)階教程》及《AngularJS MVC架構(gòu)總結(jié)》
希望本文所述對(duì)大家AngularJS程序設(shè)計(jì)有所幫助。
- 詳解AngularJS 模態(tài)對(duì)話框
- BootStrap+Angularjs+NgDialog實(shí)現(xiàn)模式對(duì)話框
- 詳解angular2封裝material2對(duì)話框組件
- AngularJS實(shí)現(xiàn)頁面跳轉(zhuǎn)后自動(dòng)彈出對(duì)話框?qū)嵗a
- AngularJs 彈出模態(tài)框(model)
- AngularJS $modal彈出框?qū)嵗a
- angularjs創(chuàng)建彈出框?qū)崿F(xiàn)拖動(dòng)效果
- Angular彈出模態(tài)框的兩種方式
- AngularJS中使用ngModal模態(tài)框?qū)嵗?/a>
- Bootstrap和Angularjs配合自制彈框的實(shí)例代碼
- 利用Angularjs和原生JS分別實(shí)現(xiàn)動(dòng)態(tài)效果的輸入框
相關(guān)文章
angularjs2中父子組件的數(shù)據(jù)傳遞的實(shí)例代碼
本篇文章主要介紹了angularjs2中父子組件的數(shù)據(jù)傳遞的實(shí)例代碼,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2017-07-07
Angular.JS利用ng-disabled屬性和ng-model實(shí)現(xiàn)禁用button效果
這篇文章主要介紹了Angular.JS利用ng-disabled屬性和ng-model實(shí)現(xiàn)禁用button效果的相關(guān)資料,文中給出了詳細(xì)的示例代碼,相信對(duì)大家具有一定的參考價(jià)值,需要的朋友們下面來一起看看吧。2017-04-04
AngularJs解決跨域問題案例詳解(簡(jiǎn)單方法)
本文通過一個(gè)案例給大家介紹angularJs解決跨域問題,非常具有參考借鑒價(jià)值,感興趣的朋友一起學(xué)習(xí)吧2016-05-05
AngularJS ng-repeat指令及Ajax的應(yīng)用實(shí)例分析
這篇文章主要介紹了AngularJS ng-repeat指令及Ajax的應(yīng)用,結(jié)合實(shí)例形式分析了ng-repeat指令的功能及ajax請(qǐng)求交互相關(guān)操作技巧,需要的朋友可以參考下2017-07-07
AngularJS中監(jiān)視Scope變量以及外部調(diào)用Scope方法
在AngularJS中,有時(shí)候需要監(jiān)視Scope中的某個(gè)變量,因?yàn)樽兞康母淖儠?huì)影響一些界面元素的顯示,接下來通過本文給大家介紹AngularJS中監(jiān)視Scope變量以及外部調(diào)用Scope方法,需要的朋友參考下吧2016-01-01
淺談AngularJs 雙向綁定原理(數(shù)據(jù)綁定機(jī)制)
本篇文章主要介紹了淺談AngularJs 雙向綁定原理(數(shù)據(jù)綁定機(jī)制),小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2017-12-12
Angular實(shí)現(xiàn)下載安裝包的功能代碼分享
本文通過實(shí)例代碼給大家介紹了angular實(shí)現(xiàn)下載安裝包的功能以及基于angularjs代碼實(shí)現(xiàn)錨點(diǎn)跳轉(zhuǎn)的功能,需要的朋友參考下吧2017-09-09
對(duì)angular 實(shí)時(shí)更新模板視圖的方法$apply詳解
今天小編就為大家分享一篇對(duì)angular 實(shí)時(shí)更新模板視圖的方法$apply詳解,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧2018-10-10

