加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

AngularJS 1.x学习<2>

发布时间:2020-12-17 10:13:37 所属栏目:安全 来源:网络整理
导读:一. $http AngularJS $http 是一个用于读取web服务器上数据的服务。 $http.get(url) 是用于读取服务器数据的函数。 div ng-app = "myApp" ng-controller = "customersCtrl" ul li ng-repeat = "x in names" {{ x.Name + ',' + x.Country }} / li / ul / div

一. $http

AngularJS $http 是一个用于读取web服务器上数据的服务。$http.get(url) 是用于读取服务器数据的函数。

 <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>

二.模块

模块定义了一个应用程序。
模块是应用程序中不同部分的容器。
模块是应用控制器的容器。
控制器通常属于一个模块。

通过 AngularJS 的 angular.module 函数来创建模块:

<script> var app = angular.module("myApp",[]); </script>

三.动画

AngularJS 提供了动画效果,可以配合 CSS 使用。AngularJS 使用动画需要引入 angular-animate.min.js

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读