您的位置:首页 > 编程语言 > Java开发

play框架中使用angular控件使用体会

2015-08-05 14:37 501 查看
这里只做了简单的描述。

(1)play后端返回值到前端

List<Coupon> list = Coupon.find(hql, params).fetch(pageindex, pagesize);
long count=Coupon.count(hql, params);
Map<String,Object> data=new HashMap<String,Object>();
data.put("count", count);
data.put("Title", list);


(2)前端接收,绑定到控件上

js如下

serve.post(url,postData,function (data){

$scope.Title = data.Title;

$scope.recordCount = data.count;

}

如果在function作用域外,则需要加上一句代码:

if(!$scope.$$phase) {
$scope.$apply();
}


html如下

<div class="col-xs-12">
<table class="table m-b-0">
<thead>
<tr class="active">
<th>标题</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="t in Title">
<td ng-bind="t.title"></td>
</tr>
</tbody>
</table>
</div>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息