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

AngularJS Toaster使用詳解

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

AngularJS Toaster是一個 AngularJS 提示框.基于angular v1.2.6 及以上和angular-animate. (推薦使用 /1.2.8/angular-animate.js, 因為高版本會有怪異閃爍.)

引入腳本

<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 屬性傳遞一個對象

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

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

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

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

這種設(shè)置會覆蓋頁面的屬性設(shè)置,不會污染其他的彈窗設(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會調(diào)用$sce.trustAsHtml(toast.body)如果解析成功將會通過ng-bind-html指令被綁定到toaster,失敗會拋出一個異常

作為模板處理

例如:

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

作為指令來處理

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ù),當彈窗被移除的時候調(diào)用,可以用于鏈式調(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就行,如果沒有符合的就自己手動添加一個到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使用詳解,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復大家的。在此也非常感謝大家對腳本之家網(wǎng)站的支持!

相關(guān)文章

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

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

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

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

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

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

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

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

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

    AngularJS入門之動畫

    AngularJS中ngAnimate模塊支持動畫效果,但是ngAnimate模塊并未包含在AngularJS核心庫中,因此需要使用ngAnimate需要在定義Module時聲明對其的引用。下面通過本文我們來看看AngularJS動畫的詳細介紹。
    2016-07-07
  • AngularJS 打開新的標簽頁實現(xiàn)代碼

    AngularJS 打開新的標簽頁實現(xiàn)代碼

    本文通過實例代碼給大家介紹了angularJS 打開新的標簽頁方法,代碼簡單易懂,非常不錯,具有參考借鑒價值,需要的朋友參考下吧
    2017-09-09
  • Angularjs使用指令做表單校驗的方法

    Angularjs使用指令做表單校驗的方法

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

    AngularJS Ajax詳解及示例代碼

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

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

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

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

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

最新評論

商城县| 八宿县| 浮梁县| 苗栗市| 肥东县| 鲁山县| 麟游县| 长葛市| 浦东新区| 毕节市| 白山市| 赤峰市| 深泽县| 白玉县| 平乐县| 罗山县| 土默特左旗| 泰州市| 三都| 宁武县| 五华县| 昌邑市| 报价| 玉山县| 沈丘县| 夹江县| 阿克苏市| 镇雄县| 峡江县| 三穗县| 黄平县| 大余县| 京山县| 苗栗市| 分宜县| 静海县| 成武县| 土默特右旗| 应用必备| 高密市| 台湾省|