手记

使用spring boot + angularJS服务接受后台数据

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8"/>
<title>Insert title here</title>
</head>
<body ng-app="app" >
<h1>index page</h1>

<h3>跳转到test页面<a href="test">click</a></h3>

<div ng-controller="ctrl">
    {{name}}
    <hr/>
    <p ng-repeat="row in rows">{{row.name}}</p>
</div>
<script src="//cdn.bootcss.com/angular.js/1.5.6/angular.min.js"></script>
<script>
    var app = angular.module("app",[]);
    app.controller("ctrl",function($scope,$http){
        $scope.name = "evan";
        $scope.data = {};
        $scope.rows = [];

        // 初始化数据
        $http({
            url : "/find",
            method : "post"
        }).success(function(rows){
            for(var i in rows){
                var row = rows[i];
                $scope.rows.push(row);
            }
        })
    })

</script>

</body>
</html>

0人推荐
随时随地看视频
慕课网APP