'use strict';

app.directive('clearArray', function () {
  return {
    restrict: 'EA',
    replace: true,
    scope: {
      array: '='
    },
    link: function(scope, element, attrs) {
      
      function clearAll() {
        var arr = scope.array;
        while(arr.length > 0) {
          arr.pop();                     
        }
      }

      element.on('click', function(event) {
        //event.preventDefault();
        scope.$apply(clearAll);
      });
    }
  };
});