0

I am trying to solve a problem.

I have a table with four field.

here you go for my controller:

app.controller('crudCtrl', function($scope, $http) {
  getAllContact = function() {
    var data = $http.get("http://127.0.0.1:8000/api/v1/contact/")
    .then(function(response) {
      $scope.contacts = response.data;
    }, function(response) {
      $scope.connectionError = "Opps ! Having Trouble in loading this page ! \n  It's Connection Error !!!";
    }); 
  };
  getAllContact();

Above snippet is working fine but i want something different like.

When in backend/database/server happen any change like update/create/delete, so that the change automatically reflected in client side without refreshing or reloading page.

Currently my code working fine if i reload the page i see the change but i dont want it with reloading. i want it instantly whenever a change occurs in backend, so that i can see the change in client side without any page refreshing or reloading.

How can i achieve this?

If you want see my client, here you go for client side snippet:

<table class="table table-striped table-light">

    <tbody>
      <tr ng-repeat="contact in contacts | filterByName track by $index ">
        <td>{{ contact.id }}</td>
        <td>{{ contact.userid }}</td>
        <td>{{ contact.name }}</td>
        <td>{{ contact.email }}</td>
        <td>{{ contact.phone }}</td>
        <td>
      </tr>
    </tbody>
  </table>
dudd
  • 372
  • 1
  • 4
  • 13
  • 3
    You need to open a WebSocket between server and client. – Bunyamin Coskuner May 20 '19 at 14:09
  • 1
    The [WebSocket API](https://developer.mozilla.org/en-US/docs/Web/API/WebSockets_API) is an advanced technology that makes it possible to open a two-way interactive communication session between the user's browser and a server. With this API, you can send messages to a server and **receive event-driven responses without having to poll the server for a reply.** – georgeawg May 20 '19 at 15:12

0 Answers0