title: ng-else directive in angularjs
body: <p>how can we create <code>ngELSE</code> directive as same as <code>ngIF</code> directive? </p>
  
  <p>below code for <code>ngIfDirective</code>. Shall we customize the code for <code>ngELSE</code>? </p>
  
  <pre><code>var ngIfDirective = ['$animate', function($animate) {
    return {
      multiElement: true,
      transclude: 'element',
      priority: 600,
      terminal: true,
      restrict: 'A',
      $$tlb: true,
      link: function($scope, $element, $attr, ctrl, $transclude) {
          var block, childScope, previousElements;
          $scope.$watch($attr.ngIf, function ngIfWatchAction(value) {
  
            if (value) {
              if (!childScope) {
                $transclude(function(clone, newScope) {
                  childScope = newScope;
                  clone[clone.length++] = document.createComment(' end ngIf: ' + $attr.ngIf + ' ');
                  // Note: We only need the first/last node of the cloned nodes.
                  // However, we need to keep the reference to the jqlite wrapper as it might be changed later
                  // by a directive with templateUrl when its template arrives.
                  block = {
                    clone: clone
                  };
                  $animate.enter(clone, $element.parent(), $element);
                });
              }
            } else {
              if (previousElements) {
                previousElements.remove();
                previousElements = null;
              }
              if (childScope) {
                childScope.$destroy();
                childScope = null;
              }
              if (block) {
                previousElements = getBlockNodes(block.clone);
                $animate.leave(previousElements).then(function() {
                  previousElements = null;
                });
                block = null;
              }
            }
          });
      }
    };
  }];
  </code></pre>