获取网络数据

<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width, initial-scale=1" >
		<title>获取网络数据</title>
		<script type="text/javascript" src="js/angular.js" ></script>
		<script>
			var app=angular.module("myapp",[]);
			app.controller("myctrl",function($scope,$location,$timeout,$interval,$http){
				$scope.myurl=$location.absUrl();
				$scope.a=$location.host();
				$scope.b=$location.protocol();
				$scope.c=$location.path();
				$scope.d=$location.port();
				
				//$timeout
				$scope.str="";
				$timeout(function(){
					$scope.str="我是2秒以后出现";
				},2000);
				//$initerval
				$scope.currentTime="";
				$interval(function(){
					var _date=new Date().toLocaleTimeString();
					$scope.currentTime=_date;
				},1000);
				//$http
				$scope.dataJson="";
				/*$http({//请求一个json  本地的
					method:"get",
					url:"haha.json"
				}).then(function success(response){//请求成功了
					$scope.dataJson=response.data;
					//debugger;
				},function error(response){//请求失败了
					
				});
				$scope.deleteP=function($index){
					$scope.dataJson.splice($index,1);
				};*/
				//通过http内置服务    请求网络数据    展示
				$scope.jsonFromNet="";
				$http({
					method:"get",
					url:"http://result.eolinker.com/pWEDzFn48fd146c3a725c1571f997a44281b94d1201b661?uri=myjson1"
				}).then(function success(response){
					
					$scope.jsonFromNet=response.data;
					//debugger;
				},function error(response){
					//debugger;
				});
				$scope.deleteG=function($index){
					$scope.jsonFromNet.data.splice($index,1);
				}
			});
		</script>
	</head>
	<body ng-app="myapp" ng-controller="myctrl">
		<center>
			<h3>获取网络 杂 练习</h3>
			<p>1  {{myurl}}</p>
			<p>2  {{a}}</p>
			<p>3  {{b}}</p>
			<p>4  {{c}}</p>
			<p>5  {{d}}</p>
			<p>{{str}}</p>
			<p>当前时间: {{currentTime}}</p>
			<!--<p>通过http服务获取本地json   展示</p>
			<table>
				<tr>
					<th>序号</th>
					<th>名字</th>
					<th>年龄</th>
					<th>性别</th>
					<th>操作</th>
				</tr>
				<tr ng-repeat="p in dataJson">
					<td>{{$index}}</td>
					<td>{{p.name}}</td>
					<td>{{p.age}}</td>
					<td>{{p.sex}}</td>
					<td><input type="button" ng-click="deleteP($index);" value="删除"/></td>
				</tr>
			</table>-->
			<p>通过http服务获取网络json   展示</p>
			<table>
				<tr>
					<th>序号</th>
					<th>detectionId</th>
					<th>detectionItem</th>
					<th width="400px">detectionInfo</th>
					<th>图片</th>
					<th>操作</th>
				</tr>
				<tr ng-repeat="g in jsonFromNet.data ">
					<td>{{$index}}</td>
					<td>{{g.detectionId}}</td>
					<td>{{g.detectionItem}}</td>
					<td>{{g.detectionInfo}}</td>
					<td><img src="http://www.sinaimg.cn/ty/deco/2013/1108/nbalogo/20.png"/></td>
					<td><input type="button" ng-click="deleteG($index);" value="删除"/></td>
				</tr>
			</table>
		</center>
	</body>
</html>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值