       list: "="
     }
     link: ($scope, $element, $attributes) ->
+
       $scope.stub = {}
       $scope.instance = $scope.stub
       $scope.stub.list = $scope.list


      thead.append tr

  {
    restrict: "AC"
    scope: true
    compile: (element, attributes, transclude) ->

      constructHeader(element)

      # TODO: better exception handling
      if attributes.pagination and attributes.list then throw "List and pagination defined on the same table."


      # TODO: better handling of the following if/else stuff

      $scope.stub.currentPage = 0

      $scope.update = () ->
        $scope.stub.currentPage = 0
        if $scope.list
          if $scope.list.length > 0
            $scope.stub.numberOfPages = Math.ceil($scope.list.length / $scope.stub.itemsPerPage)
            $scope.pages = for x in [0..($scope.stub.numberOfPages - 1)]
              x
          else
            $scope.stub.numberOfPages = 0
            $scope.pages = []
          $scope.stub.list = $scope.list

      $scope.stub.fromPage = () ->
        if $scope.list
          $scope.stub.itemsPerPage * $scope.stub.currentPage - $scope.list.length

      $scope.goToPage = (page) ->
        page = Math.max(0, page)
