Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html ng-app="app">
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.0/angular.min.js"></script>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>JS Bin</title>
</head>
<body>
  <div class="main" ng-controller="MainCtrl">   
    <div notification-bar show="error" msg="Something is wrong here :( "></div>
    
    <pre>error : {{ error }}</pre>
    <p> <button ng-click="showError()">Show Error</button> </p>
  </div>
  
</body>
</html>
 
.alert {
  padding: 10px;
  font-size: 14px;
  margin-top: -1px;
  font-style: italic;
  margin-bottom: 20px; }
  .alert.alert-danger {
    background: #F36765;
    color: #FFF; }
  .alert span {
    font-style: normal;
    font-weight: bold;
    font-size: 16px;
    padding-right: 10px; }
 
angular.module('app', []);
angular.module('app')
  .controller('MainCtrl', function($scope){
    $scope.error = true;
  
    $scope.showError = function() {
      $scope.error = true;
    };
    
  });
// Directive
angular.module('app').directive('notificationBar', [function(){
    return {
        restrict : 'A',
    scope : {
      msg : '@',
      type : '@',
      show : '='
    },
        template : '<div ng-click="hideIt()" ng-show="show" class="alert {{type}}"><span>&times;</span> {{ msg }}</div>',
    link : function ( scope, elem, attr ) {
      scope.type = attr.type || 'alert-danger';
      scope.hideIt = function () {
          scope.show = false;
      };
      scope.$watch('show', function(newValue, oldValue) {
        console.info('old show val', oldValue);
        console.info('new show val', newValue);
      });
    }
    };
}]);
Output 300px

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
anonymouspro
0viewers