当前项目的品牌列表的实现

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包,写入代码,即可完成品牌列表的实现。

猜你喜欢

转载自blog.csdn.net/Liaoyuh/article/details/81367359