[AngularJS] EasyModal - alert - confirm - modal

本文介绍了一种在AngularJS应用中使用的模态对话框工具emodal,它提供了增强的弹窗功能,如自定义样式、回调函数等,并且演示了如何创建警报、确认对话框及具有额外按钮的模态窗口。
This easyModal can be used in AngularJS-base(with Bootstrap) web application, which is an alternative of JS alert and confirm dialog with enhanced functionality(html template, css, callback, external controller, etc.), more flexible, better user experience.

This tool provides three types of modal:  alert, confirm and modal.

1. alert
This aims to provide the function like traditional JS alert, but with more customize properties.

emodal.alert("Messages go here!");
 

emodal.alert("<strong>Title</strong><p></p>Disappear in 2 seconds",
               {okLabel:'New Label',okClass:'btn btn-success',fadein:2000}
             );



  2. confirm
This aims to provide the function like traditional JS confirm, but with more customize properties.

emodal.confirm("Are you sure to delete?<p></p>It is not recoverable!",
    function(){
        // if OK is pressed
    },
    function(){
         // if Cancel is pressed
    }
);

 
 3. modal
Modal aims to provide more functionality not as simple alert and confirm dialog. Generally the argument passed in is an object with the following peoperties:

 
emodal.modal({
    template:'There are two extra buttons!',
    title:'Extra Buttons Demo',
    okCallback:okCallbackFun,
    okArgs:{id:1},
    cancelCallback:cancelCallbackFun,
    cancelArgs:{info:'some text'},
    buttons:[
               {label:'Extra-1',class:'btn btn-warning',callback:extraCallBackFun1,args:{info:'from extra button 1'}},
               {label:'Extra-2',class:'btn btn-success',callback:extraCallBackFun2,args:{info:'from extra button 2'}}
             ]
});
var okCallbackFun = function (arg) {
    $scope.data = '[ok callback] Parameter: '+arg.id;
};
var cancelCallbackFun = function (arg) {
    $scope.data = '[cancel callback] Parameter: '+arg.info;
};
var extraCallBackFun1 = function (arg) {
    $scope.data = '[extra callback 1] Parameter: '+arg.info;
};
var extraCallBackFun2 = function (arg) {
    $scope.data = '[extra callback 2] Parameter: '+arg.info;
};

 
[For online live example, see]:   
emodal online example
[For Details, see]:   
Documentation Page

[For source code, refer to]:   
easymodal.js on Github
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值