brand.html页面代码
<script type="text/javascript" src="../plugins/angularjs/angular.min.js"></script>
<script type="text/javascript">
var app=angular.module('pinyougou',[]);
app.controller('brandController',function ($scope,$http) {
$scope.findAll=function() {
$http.get('../brand/findAll.do').success(
function (response) {
$scope.list = response;
}
);
}
});
</script>
<body class="hold-transition skin-red sidebar-mini" ng-app="pinyougou" ng-controller="brandController" ng-init="findAll()" >
<tr ng-repeat="entity in list">
<td><input type="checkbox" ></td>
<td>{{entity.id}}</td>
<td>{{entity.name}}</td>
<td>{{entity.firstChar}}</td>
</tr>
BrandController
@Controller
@RequestMapping("/brand")
public class BrandController {
@Reference
private BrandService brandService;
@RequestMapping("/findAll")
@ResponseBody
public List<TbBrand> findAll(){
return brandService.findAll();
}
}
在项目搭建成功后,在brand.html页面导入angularJS包,写入代码,即可完成品牌列表的实现。