title: AngularJS datatables refresh after adding new object
body: <p>I'm trying to add new user like this :</p>
  <pre><code>$scope.users = UserService.query();
  
  UserService.save({}, newUser, function (data) {
      $scope.users.push(data);
  });
  </code></pre>
  <ul>
  <li>It's adding to server (F5 creates wanting result),</li>
  <li>checking with <code>console.log($scope.users)</code> its also added here.</li>
  </ul>
  <p>but that does not change the display</p>
  <p><strong>otherwise</strong> this works well:</p>
  <pre><code>UserService.delete({ id: userId }, function (data) {
      ...
      $scope.homeworks.splice(index, 1);
      ...
  });
  </code></pre>
  <p>How can i refresh table after array change ?</p>
  <p><strong>UPDATE 1:</strong></p>
  <p>I tried <code>$scope.$evalAsync</code> and <code>$q</code></p>
  <p><strong>UPDATE 2</strong></p>
  <p>I am using <a href="https://l-lin.github.io/angular-datatables/#/angularWay" rel="nofollow noreferrer">The Angular Way</a>, trying this :  <a href="https://l-lin.github.io/angular-datatables/#/angularWayDataChange" rel="nofollow noreferrer">Changing data with the Angular way</a></p>
  <p>Html:</p>
  <pre><code>&lt;table datatable=&quot;ng&quot; dt-options=&quot;dtOptions&quot; class=&quot;table table-striped table-bordered table-hover&quot;&gt;
      &lt;thead&gt;...&lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr ng-repeat=&quot;user in users&quot;&gt;
              &lt;td&gt;{{user.Name}}&lt;/td&gt;
              &lt;td&gt;{{user.Surname}}&lt;/td&gt;
              &lt;td&gt;{{user.Address}}&lt;/td&gt;
              ...
              ...
              ...
              &lt;td class=&quot;center&quot;&gt;
                  &lt;button type=&quot;button&quot; class=&quot;btn btn-primary btn-circle&quot; ng-click=&quot;edituser(user.Id)&quot;&gt;
                      &lt;i class=&quot;fa fa-list&quot;&gt;&lt;/i&gt;
                  &lt;/button&gt;
                  &lt;button type=&quot;button&quot; class=&quot;btn btn-danger btn-circle&quot; ng-click=&quot;deleteuser(user.Id)&quot;&gt;
                      &lt;i class=&quot;fa fa-times&quot;&gt;&lt;/i&gt;
                  &lt;/button&gt;
              &lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
  &lt;/table&gt;
  </code></pre>
  <p><strong>UPDATE 3:</strong></p>
  <p>I solved:</p>
  <p>I try to call this function from modal, if I call inside of page its work.</p>