<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
.sample-animation { transition: all linear 0.5s; } .sample-animation.ng-hide { opacity: 0; } #alertDiv{ margin-top: 10px; }
var app = angular.module('app', ['ngAnimate']); app.controller('myCtrl', function($scope){ $scope.myAlert = false; $scope.action = 'Show'; $scope.show = function(){ if($scope.myAlert == false){ $scope.myAlert = true; $scope.action = 'Hide'; } else{ $scope.hide(); } } $scope.hide = function(){ $scope.myAlert = false; $scope.action = 'Show'; } });
<!DOCTYPE html> <html ng-app="app"> <head> <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"> <style type="text/css"> .sample-animation { transition: all linear 0.5s; } .sample-animation.ng-hide { opacity: 0; } #alertDiv{ margin-top: 10px; } </style> </head> <body ng-controller="myCtrl"> <div class="container"> <div class="text-center"> </div> <div class="row" id="alertDiv"> <div class="col-sm-6 col-sm-offset-3"> <div class="alert alert-success text-center sample-animation" ng-show="myAlert"> This is a sample alert </div> </div> </div> </div> <script> var app = angular.module('app', ['ngAnimate']); app.controller('myCtrl', function($scope){ $scope.myAlert = false; $scope.action = 'Show'; $scope.show = function(){ if($scope.myAlert == false){ $scope.myAlert = true; $scope.action = 'Hide'; } else{ $scope.hide(); } } $scope.hide = function(){ $scope.myAlert = false; $scope.action = 'Show'; } }); </script> </body> </html>