最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

AngularJS Toaster使用詳解

 更新時(shí)間:2017年02月24日 10:12:42   作者:培培3514  
AngularJS Toaster是一個(gè) AngularJS 提示框.基于angular v1.2.6 及以上和angular-animate.這篇文章主要介紹了AngularJS Toaster使用詳解,需要的朋友可以參考下

AngularJS Toaster是一個(gè) AngularJS 提示框.基于angular v1.2.6 及以上和angular-animate. (推薦使用 /1.2.8/angular-animate.js, 因?yàn)楦甙姹緯?huì)有怪異閃爍.)

引入腳本

<link  rel="stylesheet" />
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.0/angular.min.js" ></script>
<script src="https://code.angularjs.org/1.2.0/angular-animate.min.js" ></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angularjs-toaster/0.4.16/toaster.min.js"></script>

用法1:

添加指令

<toaster-container></toaster-container>

編寫彈窗調(diào)用函數(shù)

angular.module('main', ['toaster', 'ngAnimate'])
 .controller('myController', function($scope, toaster) {
  $scope.pop = function(){
   toaster.pop('success', "title", "text");
  };
 });

調(diào)用

<div ng-controller="myController">
 <button ng-click="pop()">Show a Toaster</button>
</div>

添加關(guān)閉按鈕

方式一: 全局的,為所有彈窗添加

<toaster-container toaster-options="{'close-button': true}"></toaster-container>

方式二:給close-btn 屬性傳遞一個(gè)對(duì)象

<toaster-container toaster-options="{'close-button':{ 'toast-warning': true, 'toast-error': false } }"></toaster-container>

表示warning類型的彈窗顯示關(guān)閉按鈕,error類型的則不顯示,不設(shè)置默認(rèn)為false不顯示

方式三 :在控制器里面設(shè)置:

toaster.pop({
   type: 'error',
   title: 'Title text',
   body: 'Body text',
   showCloseButton: true
   });

這種設(shè)置會(huì)覆蓋頁(yè)面的屬性設(shè)置,不會(huì)污染其他的彈窗設(shè)置。

自定義關(guān)閉按鈕的html

<toaster-container toaster-options="{'close-html':'<button>Close</button>', 'showCloseButton':true}"></toaster-container>

或者

toaster.pop({
  type: 'error',
  title: 'Title text',
  body: 'Body text',
  showCloseButton: true,
  closeHtml: '<button>Close</button>'
});

bodyOutputType(body的渲染類型) 可以接受 trustedHtml', ‘template', ‘templateWithData', ‘directive'四種類型
trustedHtml:使用此類型 toaster會(huì)調(diào)用$sce.trustAsHtml(toast.body)如果解析成功將會(huì)通過(guò)ng-bind-html指令被綁定到toaster,失敗會(huì)拋出一個(gè)異常

作為模板處理

例如:

$scope.pop = function(){
  toaster.pop({
   type: 'error',
   title: 'Title text',
   body: 'cont.html',
   showCloseButton: true,
   bodyOutputType:'template',
   closeHtml: '<span>wqeqwe</span>'
  });
 };

作為指令來(lái)處理

toaster.pop({
 type: 'info',
 body: 'bind-unsafe-html',
 bodyOutputType: 'directive'
});
.directive('bindUnsafeHtml', [function () {
 return {
  template: "<span style='color:orange'>Orange directive text!</span>"
 };
}])

帶數(shù)據(jù)的指令

toaster.pop({
  type: 'info',
  body: 'bind-name',
  bodyOutputType: 'directive',
  directiveData: { name: 'Bob' }
});
.directive('bindName', [function () {
  return {
   template: "<span style='color:orange'>Hi {{directiveData.name}}!</span>"
  };
}])
<toaster-container toaster-options="{'body-output-type': 'template'}"></toaster-container>

回調(diào)函數(shù),當(dāng)彈窗被移除的時(shí)候調(diào)用,可以用于鏈?zhǔn)秸{(diào)用彈窗

toaster.pop({
   title: 'A toast',
   body: 'with a callback',
   onHideCallback: function () { 
    toaster.pop({
     title: 'A toast',
     body: 'invoked as a callback'
    });
   }
});

設(shè)置彈窗位置

位置信息可以去css文件里面看需要什么位置,直接把屬性值改成相應(yīng)class就行,如果沒(méi)有符合的就自己手動(dòng)添加一個(gè)到toaster.css文件然后把名字賦值給屬性就行

<toaster-container toaster-options="{'position-class': 'toast-top-full-width'}"></toaster-container>
<toaster-container toaster-options="{'position-class': 'toast-top-center', 'close-button':true}"></toaster-container>

以上所述是小編給大家介紹的AngularJS Toaster使用詳解,希望對(duì)大家有所幫助,如果大家有任何疑問(wèn)請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)腳本之家網(wǎng)站的支持!

相關(guān)文章

  • Angular中使用$watch監(jiān)聽(tīng)object屬性值的變化(詳解)

    Angular中使用$watch監(jiān)聽(tīng)object屬性值的變化(詳解)

    下面小編就為大家?guī)?lái)一篇Angular中使用$watch監(jiān)聽(tīng)object屬性值的變化(詳解)。小編覺(jué)得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧
    2017-04-04
  • Angular4中的checkbox?全選按鈕啟用禁用

    Angular4中的checkbox?全選按鈕啟用禁用

    這篇文章主要介紹了Angular4中的checkbox?全選按鈕啟用禁用的相關(guān)資料,需要的朋友可以參考下
    2023-03-03
  • 將angular-ui的分頁(yè)組件封裝成指令的方法詳解

    將angular-ui的分頁(yè)組件封裝成指令的方法詳解

    這篇文章主要給大家介紹了將angular-ui的分頁(yè)組件封裝成指令的方法,文中介紹的非常詳細(xì),相信會(huì)對(duì)大家的學(xué)習(xí)或者工作覺(jué)有一定的參考價(jià)值,需要的朋友下面來(lái)一起看看吧。
    2017-05-05
  • Angular限制input框輸入金額(是小數(shù)的話只保留兩位小數(shù)點(diǎn))

    Angular限制input框輸入金額(是小數(shù)的話只保留兩位小數(shù)點(diǎn))

    最近做項(xiàng)目遇到這樣的需求輸入框要求輸入金額,只能輸入數(shù)字,可以是小數(shù),必須保留小數(shù)點(diǎn)后兩位。下面分為兩部分代碼給大家介紹實(shí)現(xiàn)代碼,需要的的朋友參考下吧
    2017-07-07
  • AngularJS入門之動(dòng)畫

    AngularJS入門之動(dòng)畫

    AngularJS中ngAnimate模塊支持動(dòng)畫效果,但是ngAnimate模塊并未包含在AngularJS核心庫(kù)中,因此需要使用ngAnimate需要在定義Module時(shí)聲明對(duì)其的引用。下面通過(guò)本文我們來(lái)看看AngularJS動(dòng)畫的詳細(xì)介紹。
    2016-07-07
  • AngularJS 打開(kāi)新的標(biāo)簽頁(yè)實(shí)現(xiàn)代碼

    AngularJS 打開(kāi)新的標(biāo)簽頁(yè)實(shí)現(xiàn)代碼

    本文通過(guò)實(shí)例代碼給大家介紹了angularJS 打開(kāi)新的標(biāo)簽頁(yè)方法,代碼簡(jiǎn)單易懂,非常不錯(cuò),具有參考借鑒價(jià)值,需要的朋友參考下吧
    2017-09-09
  • Angularjs使用指令做表單校驗(yàn)的方法

    Angularjs使用指令做表單校驗(yàn)的方法

    本篇文章主要介紹了Angularjs使用指令做表單校驗(yàn)的方法,詳細(xì)的介紹了用指令做校驗(yàn)的方法,具有一定的參考價(jià)值,有興趣的可以了解一下。
    2017-03-03
  • AngularJS Ajax詳解及示例代碼

    AngularJS Ajax詳解及示例代碼

    本文主要講解AngularJS Ajax的知識(shí),這里提供詳細(xì)資料及代碼示例,幫助學(xué)習(xí)AngularJS的朋友,有需要的小伙伴可以參考下
    2016-08-08
  • AngularJS  $on、$emit和$broadcast的使用

    AngularJS $on、$emit和$broadcast的使用

    本文主要介紹AngularJS $on、$emit和$broadcast的使用,這里整理了詳細(xì)的資料及簡(jiǎn)單示例代碼有興趣的小伙伴可以參考下
    2016-09-09
  • 詳解angularjs實(shí)現(xiàn)echart圖表效果最簡(jiǎn)潔教程

    詳解angularjs實(shí)現(xiàn)echart圖表效果最簡(jiǎn)潔教程

    本篇文章主要介紹了詳解angularjs實(shí)現(xiàn)echart圖表效果最簡(jiǎn)潔教程,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧
    2017-11-11

最新評(píng)論

延长县| 高要市| 竹溪县| 年辖:市辖区| 惠州市| 周口市| 南皮县| 搜索| 沙雅县| 安陆市| 涞水县| 博爱县| 中阳县| 博白县| 辛集市| 襄城县| 德保县| 新竹县| 土默特左旗| 泗阳县| 玉溪市| 乌拉特前旗| 仁布县| 淳安县| 招远市| 定安县| 武隆县| 石林| 甘南县| 福贡县| 康定县| 城步| 荃湾区| 会昌县| 东乡县| 井研县| 瑞丽市| 体育| 福海县| 清河县| 通榆县|