0

I'm using PHP/MySQL/Socket.IO/NodeJS. I'm trying to expand my website and add more functionality to it. Essentially I need to update a table when a new user is added to the table, but I need to do it with AngularJS I'm pretty sure.

<pre>
 <thead>
  <tr>
  <th>Name</th>
  <th>Risk</th>
  </tr>
</thead>
<tbody>
 <tr><td> Joe </td> <td> 5 </td> 
</tbody>

So as you can see Joe has a "Risk" Value of 5 this could change based on a couple different things. I need to know of a way to change Joe's value when a socket event is called with AngularJS or if there is another way that would be easier that would work.

1 Answer 1

1

You have a javascript model with the data and when you update the data, the view will be updated respectively. After incoming socket, you just update the $scope.users.

In your controller:

$scope.users = [
  { name: 'Joe', risk: 5 }
];

In your template:

 <thead>
  <tr>
  <th>Name</th>
  <th>Risk</th>
  </tr>
</thead>
<tbody>
 <tr ng-repeat="user in users">
    <td>{{ user.name }}</td>
    <td>{{ user.risk }}</td> 
</tbody>
Sign up to request clarification or add additional context in comments.

1 Comment

How would I populate the users model as it comes in though?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.