User61956409 posted
Hi aminsoraya,
It seems that you'd like to use AngularJS $http service to make request to your controller action and bind the returned data in your view. The following sample code work for me, you can refer to it.
@{
Layout = null;
}
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title></title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.7.2/angular.min.js"></script>
</head>
<body>
<div ng-app="PersonApp" ng-controller="PersonController">
<h1>Student List</h1>
<br />
<table class="table table-bordered">
<thead>
<tr>
<th>Id</th>
<th>Name</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="stud in students">
<td>{{stud.Id}}</td>
<td>{{stud.Name}}</td>
</tr>
</tbody>
</table>
</div>
</body>
</html>
<script>
var PersonApp = angular.module('PersonApp', []);
PersonApp.controller('PersonController', function ($scope, PersonService) {
window.setInterval(function () {
getPersons();
}, 5000);
function getPersons() {
PersonService.getPersons().then(function (studs) {
$scope.students = studs;
});
}
});
PersonApp.factory('PersonService', ['$http', function ($http) {
var PersonService = {};
PersonService.getPersons = function () {
return $http.get('/Home/GetData').then(function mySuccess(response) {
return response.data;
}, function myError(response) {
return response.statusText;
});
};
return PersonService;
}]);
</script>
Test Result:

With Regards,
Fei Han