目前我用angularjs 的ajax获取的数据,可以用angularjs进行数据绑定,而通过mui.ajax 获取的数据却无法进行数据绑定,请帮忙分析一下原因
<!DOCTYPE html>
<html ng-app>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
<title></title>
<script src="js/mui.min.js"></script>
<script src="js/angular-all.min.js"></script>
<link href="css/mui.min.css" rel="stylesheet"/>
<script type="text/javascript" charset="utf-8">
mui.init();
</script>
</head>
<body>
<div ng-controller="TestCtrl">
sss
<ul>
<li ng-repeat="x in names">
{{x.Name}}
</li>
</ul>
dd
</div>
<script>
var TestCtrl3=function($scope,$http){
var p=$http({
method:'get',
url:'http://www.w3cschool.cc/try/angularjs/data/Customers_JSON.php',
});
p.success(function(response,status,headers,config){
alert(response[0].Name);
$scope.names=response;
});
p.error(function(status){
alert(status);
});
}
var TestCtrl=function($scope,$http) {
mui.ajax("http://www.w3cschool.cc/try/angularjs/data/Customers_JSON.php",{
data:{
},
dataType:'json',//服务器返回json格式数据
type:'get',//HTTP请求类型
timeout:0,//超时时间设置为10秒;
success: function(data){
alert(data[0].Name);
$scope.names=eval(data);
},
error:function(xhr,type,errorThrown){
//异常处理;
}
});
}
</script>
</body>
</html>
粥冰 (作者)
谢谢,angularjs用的少,成功了,thanks
2015-06-04 15:22