• AngularJS(5)-Http


    $http 是 AngularJS 中的一个核心服务,用于读取远程服务器的数据

    加入下面有一个存储在web服务器上的数据,假设地址为http://TestWebData/myData.php

    {
    "records":
    [
    {
    "Name" : "Alfreds Futterkiste",
    "City" : "Berlin",
    "Country" : "Germany"
    },
    {
    "Name" : "Berglunds snabbköp",
    "City" : "Luleå",
    "Country" : "Sweden"
    },
    {
    "Name" : "Centro comercial Moctezuma",
    "City" : "México D.F.",
    "Country" : "Mexico"
    },
    {
    "Name" : "Ernst Handel",
    "City" : "Graz",
    "Country" : "Austria"
    },
    {
    "Name" : "FISSA Fabrica Inter. Salchichas S.A.",
    "City" : "Madrid",
    "Country" : "Spain"
    },
    {
    "Name" : "Galería del gastrónomo",
    "City" : "Barcelona",
    "Country" : "Spain"
    },
    {
    "Name" : "Island Trading",
    "City" : "Cowes",
    "Country" : "UK"
    },
    {
    "Name" : "Königlich Essen",
    "City" : "Brandenburg",
    "Country" : "Germany"
    },
    {
    "Name" : "Laughing Bacchus Wine Cellars",
    "City" : "Vancouver",
    "Country" : "Canada"
    },
    {
    "Name" : "Magazzini Alimentari Riuniti",
    "City" : "Bergamo",
    "Country" : "Italy"
    },
    {
    "Name" : "North/South",
    "City" : "London",
    "Country" : "UK"
    },
    {
    "Name" : "Paris spécialités",
    "City" : "Paris",
    "Country" : "France"
    },
    {
    "Name" : "Rattlesnake Canyon Grocery",
    "City" : "Albuquerque",
    "Country" : "USA"
    },
    {
    "Name" : "Simons bistro",
    "City" : "København",
    "Country" : "Denmark"
    },
    {
    "Name" : "The Big Cheese",
    "City" : "Portland",
    "Country" : "USA"
    },
    {
    "Name" : "Vaffeljernet",
    "City" : "Århus",
    "Country" : "Denmark"
    },
    {
    "Name" : "Wolski Zajazd",
    "City" : "Warszawa",
    "Country" : "Poland"
    }
    ]
    }
    

      

    AngularJS 实例
    <div ng-app="myApp" ng-controller="customersCtrl"> 
    
    <ul>
      <li ng-repeat="x in names">
        {{ x.Name + ', ' + x.Country }}
      </li>
    </ul>
    
    </div>
    
    <script>
    var app = angular.module('myApp', []);
    app.controller('customersCtrl', function($scope, $http) {
        $http.get("http://www.runoob.com/try/angularjs/data/Customers_JSON.php")
        .success(function(response) {$scope.names = response.records;});
    });
    </script>
    

      

  • 相关阅读:
    小程序学习资料
    tomcat单应用多实例部署报错 应用jar不存在
    nginx windows版本 1024限制
    mysql连接数
    rocketmq
    nginx路径匹配
    war包的压缩解压缩
    IIS访问HTTP Error 400. The request hostname is invalid
    Microsoft 安全扫描程序
    vscode
  • 原文地址:https://www.cnblogs.com/yk123/p/5911809.html
Copyright © 2020-2023  润新知