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

AngularJS全局警告框?qū)崿F(xiàn)方法示例

 更新時(shí)間:2017年05月18日 08:52:39   作者:timelessmemoryli  
這篇文章主要介紹了AngularJS全局警告框?qū)崿F(xiàn)方法,結(jié)合實(shí)例形式分析了AngularJS全局警告框的實(shí)現(xiàn)步驟與相關(guān)操作技巧,需要的朋友可以參考下

本文實(shí)例講述了AngularJS全局警告框?qū)崿F(xiàn)方法。分享給大家供大家參考,具體如下:

<!DOCTYPE html>
<html lang="zh-CN">
 <head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="bootstrap.min.css" rel="external nofollow" >
  <script src="jquery.min.js"></script>
  <script src="angular.js"></script>
  <script src="angular-animate.js"></script>
  <script src="bootstrap.min.js"></script>
  <script type="text/javascript">
    var myapp = angular.module('myapp', ['ngAnimate']);
    myapp.controller('msgController', ['$scope', 'notificationService', function($scope, notificationService) {
      $scope.msg = notificationService;
      $scope.show = function() {
        notificationService.danger('success');
      }
    }]);
    myapp.controller('controller', ['$scope', 'notificationService', function($scope, notificationService) {
      $scope.show = function() {
        notificationService.info('info');
      }
    }]);
    myapp.directive('msgBox', function() {
      return {
        restrict : 'EA',
        scope : {
          content: '@',
          type: '@',
        },
        templateUrl : 'tmpl.html',
        link : function(scope, elem, attrs) {
          scope.close = function() {
            scope.content = '';
          };
        }
      };
    });
    myapp.factory('notificationService', function($timeout, $rootScope) {
      return {
        content : '',
        type : '',
        success : function(content) {
          this.tmpl(content, 'success')
        },
        info : function(content) {
          this.tmpl(content, 'info')
        },
        warning : function(content) {
          this.tmpl(content, 'warning')
        },
        danger : function(content) {
          this.tmpl(content, 'danger')
        },
        tmpl : function(content, type) {
          this.content = content;
          this.type = type;
          var _self = this;
          $timeout(function() {
            _self.clear();
          }, 5000);
        },
        clear : function() {
          this.content = '';
          this.type = '';
        }
      };
    });
  </script>
  <style type="text/css">
    .msg-box {
      z-index: 666;
      position: absolute;
      width: 100%;
      top: 5px;
    }
    .msg.ng-enter {
      transition: 2s linear all;
      opacity: 0.3;
    }
    .msg.ng-enter-active {
      opacity: 1;
    }
    .msg.ng-leave {
      transition: 2s linear all;
      opacity: 1;
    }
    .msg.ng-leave-active {
      opacity: 0;
    }
  </style>
 </head>
 <body ng-app="myapp" ng-controller="msgController">
   <msg-box content="{{msg.content}}" type="{{msg.type}}" class="msg-box">
   </msg-box>
   <h1>content</h1>
   <button type="button" class="btn btn-primary" ng-click="show()">success</button>
   <div ng-controller="controller">
    <button type="button" class="btn btn-primary" ng-click="show()">info</button>
   </div>
 </body>
</html>

<div class="alert alert-{{type || 'info'}} msg" role="alert" ng-if="content">
 <button type="button" class="close" aria-label="Close" ng-click="close()">
  <span aria-hidden="true">&times;</span>
 </button>
 {{content}}
</div>

更多關(guān)于AngularJS相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《AngularJS指令操作技巧總結(jié)》、《AngularJS入門與進(jìn)階教程》及《AngularJS MVC架構(gòu)總結(jié)

希望本文所述對(duì)大家AngularJS程序設(shè)計(jì)有所幫助。

相關(guān)文章

  • 詳解Angular6學(xué)習(xí)筆記之主從組件

    詳解Angular6學(xué)習(xí)筆記之主從組件

    這篇文章主要介紹了詳解Angular6學(xué)習(xí)筆記之主從組件,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧
    2018-09-09
  • AngularJS基礎(chǔ) ng-class-odd 指令示例

    AngularJS基礎(chǔ) ng-class-odd 指令示例

    本文主要介紹AngularJS ng-class-odd 指令,這里對(duì)ng-class-odd基礎(chǔ)知識(shí)做了詳細(xì)整理,并有示例代碼和效果圖,學(xué)習(xí)AngularJS的同學(xué)可以參考下
    2016-08-08
  • AngularJS入門教程之路由機(jī)制ngRoute實(shí)例分析

    AngularJS入門教程之路由機(jī)制ngRoute實(shí)例分析

    這篇文章主要介紹了AngularJS入門教程之路由機(jī)制ngRoute,結(jié)合實(shí)例形式分析了AngularJS路由機(jī)制的原理、ngRoute的組成、配置、參數(shù)與相關(guān)使用技巧,需要的朋友可以參考下
    2016-12-12
  • angularjs使用directive實(shí)現(xiàn)分頁組件的示例

    angularjs使用directive實(shí)現(xiàn)分頁組件的示例

    本篇文章主要介紹了angularjs使用directive實(shí)現(xiàn)分頁組件的示例,具有一定的參考價(jià)值,有興趣的可以了解一下。
    2017-02-02
  • AngularJS基礎(chǔ) ng-include 指令示例講解

    AngularJS基礎(chǔ) ng-include 指令示例講解

    本文主要介紹AngularJS ng-include 指令,這里對(duì)ng-include 指令的知識(shí)做了詳細(xì)整理介紹,有需要的朋友可以參考下
    2016-08-08
  • AngularJS學(xué)習(xí)筆記之ng-options指令

    AngularJS學(xué)習(xí)筆記之ng-options指令

    ng-options是angular-1.3新出的一個(gè)指令,這篇文章就來介紹這個(gè)指令的用法.有需要的小伙伴可以參考下。
    2015-06-06
  • ng-alain表單使用方式詳解

    ng-alain表單使用方式詳解

    這篇文章主要介紹了ng-alain表單使用方式詳解,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧
    2018-07-07
  • AngularJS折疊菜單實(shí)現(xiàn)方法示例

    AngularJS折疊菜單實(shí)現(xiàn)方法示例

    這篇文章主要介紹了AngularJS折疊菜單實(shí)現(xiàn)方法,結(jié)合完整實(shí)例形式分析了AngularJS實(shí)現(xiàn)折疊菜單的具體步驟與相關(guān)操作技巧,需要的朋友可以參考下
    2017-05-05
  • AngularJS HTML編譯器介紹

    AngularJS HTML編譯器介紹

    這篇文章主要介紹了AngularJS HTML編譯器介紹,AngularJS的HTML編譯器能讓瀏覽器識(shí)別新的HTML語法。它能讓你將行為關(guān)聯(lián)到HTML元素或者屬性上,甚至能讓你創(chuàng)造具有自定義行為的新元素,需要的朋友可以參考下
    2014-12-12
  • AngularJs 國(guó)際化(I18n/L10n)詳解

    AngularJs 國(guó)際化(I18n/L10n)詳解

    本文主要介紹AngularJs 國(guó)際化的知識(shí),這里整理了詳細(xì)的資料來講解國(guó)際化,有需要的小伙伴可以參考下
    2016-09-09

最新評(píng)論

泸州市| 松江区| 郯城县| 莲花县| 策勒县| 远安县| 武邑县| 罗田县| 安多县| 和田县| 鸡泽县| 逊克县| 南澳县| 阳山县| 偃师市| 布拖县| 临湘市| 贵阳市| 西安市| 铜川市| 和平县| 泰安市| 兰考县| 新疆| 千阳县| 浦县| 仙居县| 平塘县| 化州市| 信阳市| 搜索| 仁怀市| 延川县| 南阳市| 大连市| 景洪市| 灵武市| 江口县| 乌兰察布市| 博兴县| 镇赉县|