AngularJS Ajax detailed explanation and sample code, angularjsajax

Source: Internet
Author: User

AngularJS Ajax detailed explanation and sample code, angularjsajax

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

[{"Name" : "Mahesh Parashar","RollNo" : 101,"Percentage" : "80%"},{"Name" : "Dinkar Kad","RollNo" : 201,"Percentage" : "70%"},{"Name" : "Robert","RollNo" : 191,"Percentage" : "75%"},{"Name" : "Julian Joe","RollNo" : 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:

The above is the basic information of AngularJS Ajax. We will continue to sort out relevant information in the future. Thank you for your support for this site!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.