angularjs服务 $http

angularjs服务 $http

<!DOCTYPE html>
<html ng-app="test">
<head>
<meta charset="utf-8">
<script src="angular.min.js"></script>
<script>
var app=angular.module('test',[]);
// alert(app);
app.controller('zhangsan',function($scope,$http){
	// $http.get(url,参数)
	// $http.post()
	// a.php?a=xxx&b=xxx=>
	$http.get('a.php',{
			params:{a:12,b:6},
			responseType:'json'
		}).then(function(res){
		alert(res.data+5);
	},function(){
		alert("失败了");
	});
});
</script>
</head>
<body ng-controller="zhangsan">
	
</body>
</html>

  a.php

<?php
echo $_GET['a']+$_GET['b'];
?>

  

猜你喜欢

转载自www.cnblogs.com/zzws/p/9113964.html