title: AngularJS - Refresh after POST
body: <p>What is the correct way to refresh content after a http POST request in Angular?</p>
  
  <pre><code>//controller.js
  var hudControllers = angular.module('hudControllers', []);
  
  hudControllers.controller('PropertyDetailsCtrl', 
    ['$scope','$window','$http', function ($scope,$window,$http) {
  
     //I want to reload this once the newCommentForm below has been submitted
     $http.get('/api/comments')
      .success(function(data) {$scope.comments = {"data":data};}})
      .error(function(data) {...);
  
     $scope.newCommentForm = function(){
  
        newComment=$scope.newComment;
        requestUrl='/api/comments';
        var request = $http({method: "post",url: requestUrl,data: {...}});
        request.success(function(){
          //How do I refresh/reload the comments?
          $scope.comments.push({'comment':'test'}); //Returns error - "TypeError: undefined is not a function"
        });
    };
  
  }]);
  
  //template.ejs
  &lt;div class="comment"&gt;
    &lt;ul&gt;
       &lt;li ng-repeat="comment in comments.data"&gt;{{comment.comment}}&lt;/li&gt;
   &lt;/ul&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>Thanks.</p>