验证中...
码云 IDEA 插件最新版本发布,支持 Pull Request
angularjs中想用jQuery进行数据交互的注意事项
Raw Copy
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>标题</title>
<meta name="keywords" content="">
<meta name="description" content="">
<script src="http://cdn.static.runoob.com/libs/angular.js/1.4.6/angular.min.js"></script>
<script src="https://code.jquery.com/jquery-3.3.1.js"></script>
<script>
let mod = angular.module('test_ajax', []);
mod.controller('main', function ($scope) {
$.ajax({
url:'data/arr.txt',
dataType:'json',
success(res) {
$scope.arr = res;
$scope.$apply(); // 检查$scope 上的数据是否发生了变化(angualrjs 引用外部库时 异步交互注意事项)
},
error() {
alert('错了');
}
});
})
</script>
</head>
<body ng-app="test_ajax">
<div ng-controller="main">
<ul>
<li ng-repeat="item in arr">{{item}}</li>
</ul>
</div>
</body>
</html>

Comment list( 0 )

You need to Sign in for post a comment

Help Search