AngularJS Http
$ http AngularJS is a core service for reading data from a remote server.
Read JSON file
The following is a JSON file stored on a web server:
https://w3big.com/try/angularjs/data/sites.php
AngularJS $ http
AngularJS $ http service is used to read data on a web server.
$ Http.get (url) function is used to read the data server.
AngularJS examples
try it"
Application Analysis:
? Note: get a request code above is the site server, you can not be copied directly to your local run, there will be cross-domain problem, the solution is to copy Customers_JSON.php data to your own server, with: PHP Ajax cross-domain problem the best solution.
AngularJS application defined by ng-app. Application execution in the <div> in.
ng-controller instruction set controller object name.
CustomersController function is a standard JavaScript object constructor.
The controller object has a property: $ scope.names.
$ http.get () reads the static JSON data from the web server.
Server data file: https://w3big.com/try/angularjs/data/sites.php .
When loading JSON data from the server, $ scope.names into an array.
This code can also be used to read database data. |