<script type="text/javascript">
var m1 = angular.module('myApp',[]);
m1.controller('Aaa',['$scope','$http',function($scope,$http){
$http({
method : 'GET',
url : 'http/data.php',
}).success(function(data,state,headers,config){
console.log(data,state,headers(),config);
}).error(function(data){
console.log(data);
});
}]);
</script>
//get
$http.get('http/data.php').success(function(data,state,headers,config){
console.log(data);
}).error(function(data){
console.log(data);
});
//post
$http.post('http/data.php',{
name : 'xiecg',
age : 18
}).success(function(data,state,headers,config){
console.log(data);
}).error(function(data){
console.log(data);
});
<div ng-controller="Aaa">
<input type="text" ng-model="name" ng-keyup="change(name)">
<input type="button" ng-click="change(name)" value="搜索">
<ul>
<li ng-repeat="d in data">{{d}}</li>
</ul>
</div>
<script type="text/javascript">
var m1 = angular.module('myApp',[]);
m1.controller('Aaa',['$scope','$http','$timeout',function($scope,$http,$timeout){
var timer = null;
$scope.data = [];
$scope.change = function(name){
$timeout.cancel(timer);
timer = $timeout(function(){
$http({
method : 'JSONP',
url : 'https://sp0.baidu.com/5a1Fazu8AA54nxGko9WTAnF6hhy/su?wd='+name+'&cb=JSON_CALLBACK',
}).success(function(data,state,headers,config){
console.log(data);
$scope.data = data.s;
}).error(function(data){
console.log(data);
});
},500);
};
}]);
</script>
<script type="text/javascript">
var m1 = angular.module('myApp',[]);
m1.controller('Aaa',['$scope','$location',function($scope,$location){
var absUrl = $location.absUrl(); //URL地址
//$location.path('aaa').replace(); //禁止历史管理
var path = $location.path(); //文件路径,路由
//$location.hash('hello'); //设置哈希值
//$location.search({'age' : '19'}); //设置数据
var hash = $location.hash();
var url = $location.url(); //数据
var host = $location.host(); //主机名
var port = $location.port(); //端口号
var protocol = $location.protocol();//协议
console.log(protocol);
}]);
</script>
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有