I have 2 endpoints (which I do not think they are related) from jpholder
:
jpholder/tds
jpholder/us
The best thing for you to do would be, if you had a users table and a todos table in a database, to make a SELECT with JOINing on the tables and get the user name to come out as part of the todo list by referencing users to the todo userId.
Alternatively, if you're only using fixed JSON or javascript arrays, then you can do something like this:
<tbody>
<tr ng-repeat="todo in todos ">
<td>{{todo.userId}}</td>
<td>{{::returnUserName(todo.userId)}}</td><!--Should give you the correct username.-->
<td>{{todo.title}}</td>
<td>{{todo.completed?'COMPLETED':'INCOMPLETE'}}</td>
<td> <button type="button" ng-click="UpdateTodo($index, true)" class="btn btn-info">Update</button> </td>
</tr>
</tbody>
And then for the javascript make a $scope variable:
$scope.users = [{id: 1, name:'John Doe'},{id:2, name:'Jane Appleseed'}];
$scope.returnUserName = function(userID) {
var i, len;
for (len = $scope.users.length, i=0; i<len; ++i) {
if($scope.users[i].id == userID) {
return $scope.users[i].name;
}
}
return 'No user found.'
}