Use AJAX in AngularJS, while angularjs uses ajax
AngularJS provides $ http control to read data from the server as a service. The server can call a database to obtain records. AngularJS requires data in JSON format. Once data is ready, $ http can obtain data from the server in the following ways.
function studentController($scope,$http) {var url="data.txt"; $http.get(url).success( function(response) { $scope.students = response; });}
Here, the student records included in data.txt. $ Http service enables Ajax to call and set attributes for its students. The "student" model can be used to draw HTML tables.
Example
Data.txt
Copy codeThe Code is as follows :[
{
"Name": "Mahesh Parashar ",
"Maid": 101,
"Percentage": "80%"
},
{
"Name": "Dinkar Kad ",
"Maid": 201,
"Percentage": "70%"
},
{
"Name": "Robert ",
"Maid": 191,
"Percentage": "75%"
},
{
"Name": "Julian Joe ",
"Maid": 111,
"Percentage": "77%"
}
]
TestAngularJS.html
Output
To run this example, deploy textangularjs.html and data.txt to a network server. Use urlto open textangularjs.html in the webbrowser to request the server. The result is as follows: