欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

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)文章

  • AngularJS應(yīng)用開發(fā)思維之依賴注入3

    AngularJS應(yīng)用開發(fā)思維之依賴注入3

    這篇文章主要為大家詳細介紹了AngularJS應(yīng)用開發(fā)思維之依賴注入第三篇,感興趣的小伙伴們可以參考一下
    2016-08-08
  • AngularJS自動表單驗證

    AngularJS自動表單驗證

    這篇文章主要介紹了AngularJS手動表單驗證的相關(guān)資料,AngularJS的表單驗證大致有兩種,一種是手動驗證,一種是自動驗證,本文重點介紹AngularJS自動表單驗證,感興趣的小伙伴們可以參考一下
    2016-02-02
  • 掌握Queries設(shè)計模式優(yōu)化Angular應(yīng)用開發(fā)技巧

    掌握Queries設(shè)計模式優(yōu)化Angular應(yīng)用開發(fā)技巧

    這篇文章主要介紹了掌握Queries設(shè)計模式優(yōu)化Angular應(yīng)用開發(fā)的技巧示例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪
    2023-10-10
  • AngularJS Phonecat實例講解

    AngularJS Phonecat實例講解

    這篇文章主要為大家詳細介紹了AngularJS Phonecat實例,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2016-11-11
  • Angularjs 與 bower安裝和使用詳解

    Angularjs 與 bower安裝和使用詳解

    這篇文章主要介紹了Angularjs 與 bower安裝和使用詳解的相關(guān)資料,需要的朋友可以參考下
    2017-05-05
  • Angular-Ui-Router+ocLazyLoad動態(tài)加載腳本示例

    Angular-Ui-Router+ocLazyLoad動態(tài)加載腳本示例

    本篇文章主要介紹了Angular-Ui-Router+ocLazyLoad動態(tài)加載腳本示例,可以提高加載速度,使用戶體驗更好,有興趣的可以了解一下。
    2017-03-03
  • AngularJS 表單驗證手機號的實例(非必填)

    AngularJS 表單驗證手機號的實例(非必填)

    下面小編就為大家?guī)硪黄狝ngularJS 表單驗證手機號的實例(非必填)。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2017-11-11
  • 詳解Angular調(diào)試技巧之報錯404(not found)

    詳解Angular調(diào)試技巧之報錯404(not found)

    本篇文章主要介紹了詳解Angular調(diào)試技巧之報錯404(not found),小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2018-01-01
  • AngularJS動態(tài)添加數(shù)據(jù)并刪除的實例

    AngularJS動態(tài)添加數(shù)據(jù)并刪除的實例

    下面小編就為大家分享一篇AngularJS動態(tài)添加數(shù)據(jù)并刪除的實例,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2018-02-02
  • 對Angular中單向數(shù)據(jù)流的深入理解

    對Angular中單向數(shù)據(jù)流的深入理解

    這篇文章主要給大家介紹了關(guān)于對Angular中單向數(shù)據(jù)流的深入理解,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧。
    2018-03-03

最新評論