前端
<div class=@H_404_9@"mt-20" ng-app=@H_404_9@"myapp" id=@H_404_9@"myapp" ng-controller=@H_404_9@"testcontroller"> <table class=@H_404_9@"table table-border table-bordered table-bg table-hover table-sort"> <thead> <tr class=@H_404_9@"text-c"> <th width=@H_404_9@"80">编号</th> <th width=@H_404_9@"80">单页ID</th> <th width=@H_404_9@"120">单页标题</th> <th width=@H_404_9@"120">排序数字</th> </tr> </thead> <tbody> <tr class=@H_404_9@"text-c" ng-repeat=@H_404_9@"item in items"> <td>{{$index+1}}</td> <td>{{item.db_id}}</td> <td>{{item.db_title}}</td> <td>{{item.db_sort}}</td> </tr> </tbody> </table> </div>
js
/** * Created by Administrator on 2017/5/4. */
myapp=angular.module('myapp',[]);
/* 绑定控制器*/
myapp.controller("testcontroller",function testcontroller($scope){
$scope.Search=function(){
//参数一: 请求地址
//参数二:传参
$.post(GetUrl,{name:1,page:page})
.success(function (res) {
obj = JSON.parse(res);
console.log(obj.err);
$scope.$apply(function () {
$scope.items = obj.err;
})
})
.error(function (err) {
})
.complete(function () {
})
}
})
function Search(){
$scope = angular.element($('#myapp')).scope();
$scope.Search();
}
var GetUrl="<?=Url::toRoute("/back/tests/list")?>";
$(function () {
Search();
})