zoukankan      html  css  js  c++  java
  • AngularJS $http

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

     1 <div ng-app="myApp" ng-controller="customersCtrl"> 
     2 
     3 <ul>
     4   <li ng-repeat="x in names">
     5     {{ x.Name + ', ' + x.Country }}
     6   </li>
     7 </ul>
     8 
     9 </div>
    10 
    11 <script>
    12 var app = angular.module('myApp', []);
    13 app.controller('customersCtrl', function($scope, $http) {
    14   $http.get("test.json")
    15   .success(function (response) {$scope.names = response.records;});
    16 });
    17 </script>

    AngularJS 应用通过 ng-app 定义。应用在 <div> 中执行。

    ng-controller 指令设置了 controller 对象 名。

    函数 customersController 是一个标准的 JavaScript 对象构造器

    控制器对象有一个属性: $scope.names

    $http.get() 从web服务器上读取静态 JSON 数据

    当从服务端载入 JSON 数据时,$scope.names 变为一个数组。

    努力吧,为了媳妇儿,为了家。。。
  • 相关阅读:
    data guard switchover切换异常
    oracle dataguard
    建立信任关系
    sqlplus 打印很乱,而且很短就换行
    老友记英语
    每天读一遍
    extern的用法
    linux信号处理
    http server v0.1_http_parse.c
    http server v0.1_http_webapp.c
  • 原文地址:https://www.cnblogs.com/jlj9520/p/5013238.html
Copyright © 2011-2022 走看看