国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 語言 > JavaScript > 正文

AngularJS全局警告框實現方法示例

2024-05-06 15:17:04
字體:
來源:轉載
供稿:網友

本文實例講述了AngularJS全局警告框實現方法。分享給大家供大家參考,具體如下:

<!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>            
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表

圖片精選

主站蜘蛛池模板: 海安县| 外汇| 元谋县| 马尔康县| 铜陵市| 淳化县| 乌拉特前旗| 华池县| 东阳市| 临武县| 凌源市| 鄂州市| 常宁市| 濮阳县| 祁东县| 措美县| 嘉兴市| 承德县| 宁陵县| 天全县| 河曲县| 莱州市| 海南省| 涿州市| 五峰| 博乐市| 南投县| 乾安县| 苏州市| 留坝县| 老河口市| 黄石市| 景宁| 遂昌县| 惠水县| 绩溪县| 洱源县| 汽车| 塔城市| 广东省| 罗田县|