title: AngularJS remove last element of array in scope
body: <p>I have my controller in Angular which contains an array and a delete method</p>
  
  <pre><code>function($scope, $http){
      $scope.arrayOfObjects = [];
      $scope.remove = function(obj){
          var i = $scope.arrayOfObjects.indexOf(obj);
          if( i &gt; -1 ){
              $scope.arrayOfObjects.splice(i, 1);
          }
      }
  // Some other things
  }
  </code></pre>
  
  <p>HTML</p>
  
  <pre><code>&lt;a href ng-repeat="(key, obj) in arrayOfObjects track by $index"&gt;{{obj.id}}
  
  &lt;button type="button" role="button" class="btn btn-default" ng-click="remove(obj)"&gt;
     &lt;i class="fa fa-trash"&gt;&lt;/i&gt;
     &lt;span&gt;Delete&lt;/span&gt;
  &lt;/button&gt;
  
  &lt;/a&gt;
  </code></pre>
  
  <p>Now all works well when I delete an object other than the last. When the user presses on the delete button for the last object, the page gets redirected to localhost:3000/# which is not mapped to anything and I get a blank page.</p>
  
  <p>Has anyone encountered such behavior?</p>