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

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

  • 深入理解Angularjs向指令傳遞數(shù)據(jù)雙向綁定機(jī)制

    深入理解Angularjs向指令傳遞數(shù)據(jù)雙向綁定機(jī)制

    這篇文章主要深入的給大家介紹了Angularjs向指令傳遞數(shù)據(jù),雙向綁定機(jī)制的相關(guān)資料,需要的朋友可以參考下
    2016-12-12
  • AngularJS入門教程之更多模板詳解

    AngularJS入門教程之更多模板詳解

    本文主要介紹AngularJS模板的資料知識(shí),這里幫大家整理了詳細(xì)的模版資料,及實(shí)現(xiàn)示例代碼,幫助大家學(xué)習(xí)AngularJS的知識(shí),有需要的小伙伴可以參考下
    2016-08-08
  • 詳解Angular路由 ng-route和ui-router的區(qū)別

    詳解Angular路由 ng-route和ui-router的區(qū)別

    這篇文章主要介紹了詳解Angular路由 ng-route和ui-router的區(qū)別,分別介紹了兩種路由的用法和區(qū)別,有興趣的可以了解一下
    2017-05-05
  • AngularJS基于factory創(chuàng)建自定義服務(wù)的方法詳解

    AngularJS基于factory創(chuàng)建自定義服務(wù)的方法詳解

    這篇文章主要介紹了AngularJS基于factory創(chuàng)建自定義服務(wù)的方法,結(jié)合實(shí)例形式分析了AngularJS使用factory創(chuàng)建自定義服務(wù)的具體步驟、操作技巧與相關(guān)注意事項(xiàng),需要的朋友可以參考下
    2017-05-05
  • 詳解angularJs模塊ui-router之狀態(tài)嵌套和視圖嵌套

    詳解angularJs模塊ui-router之狀態(tài)嵌套和視圖嵌套

    這篇文章主要介紹了詳解angularJs模塊ui-router之狀態(tài)嵌套和視圖嵌套,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2017-04-04
  • AngularJS的ng-click傳參的方法

    AngularJS的ng-click傳參的方法

    本篇文章主要介紹了AngularJS的ng-click傳參的方法,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧
    2017-06-06
  • 舉例講解AngularJS中的模塊

    舉例講解AngularJS中的模塊

    這篇文章主要介紹了AngularJS中的模塊,文中講到了其應(yīng)用模塊和控制器模塊的例子,需要的朋友可以參考下
    2015-06-06
  • 詳解angularJs中自定義directive的數(shù)據(jù)交互

    詳解angularJs中自定義directive的數(shù)據(jù)交互

    這篇文章主要介紹了詳解angularJs中自定義directive的數(shù)據(jù)交互,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧
    2017-01-01
  • 詳解AngularJS 模態(tài)對(duì)話框

    詳解AngularJS 模態(tài)對(duì)話框

    在涉及GUI程序開(kāi)發(fā)的過(guò)程中,常常有模態(tài)對(duì)話框以及非模態(tài)對(duì)話框的概念。接下來(lái)通過(guò)本文給大家介紹AngularJS 模態(tài)對(duì)話框 ,感興趣的朋友一起學(xué)習(xí)吧
    2016-04-04
  • AngularJs入門教程之環(huán)境搭建+創(chuàng)建應(yīng)用示例

    AngularJs入門教程之環(huán)境搭建+創(chuàng)建應(yīng)用示例

    這篇文章主要介紹了AngularJs入門教程之環(huán)境搭建+創(chuàng)建應(yīng)用的方法,較為詳細(xì)的分析了AngularJS的功能、下載及應(yīng)用創(chuàng)建方法,需要的朋友可以參考下
    2016-11-11

最新評(píng)論