我在angularjs和spring-data-rest中遇到以下问题。我想创建一个收费视图。因此,在我的html中,我有一个费用表,其中包含不同的费用。
<table class="table table-striped table-bordered table-hover">
<thead>
<tr>
<th>Name</th>
<th>Setup in <i class="glyphicon glyphicon-euro"></i></th>
<th>Basic Period</th>
<th class="text-right">{{ 'ACTIONS' | translate }}</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="fee in billing">
<td>{{ fee.name }}</td>
<td><span ng-hide="editMode">{{ fee.setupAmountEur }}</span></td>
<td><span ng-hide="editMode">{{ fee.basic.period }}</span></td>
<td>
<a class="btn btn-info pull-right" href="{{fee._links.self.href}}">{{ 'FEES_LINK' | translate }}</a>
</td>
</tr>
</tbody>
</table>
当我单击FEES_LINK时,浏览器将显示纯json。我想要的是拥有一个新的HTML站点。所以我不知道我该如何做角度的http.get到我的自我链接?
有人可以帮忙吗?
_links.self.href
是一个技术链接,可告知应用程序当前的可能过渡/操作resource
。通过设计,它返回由标识的资源的表示URI
。资源可能具有服务器可能的表示形式。JSON,XML或HTML。
服务器应根据Accept
标头返回正确的表示格式。
application/json
应该返回JSON。application/xml
应该返回XML并且text/html
应该返回HTML格式。
关于您的问题,我只是将链接包装在一个函数中,然后通过$ http获取数据。
<a class="btn btn-info pull-right" ng-click="load(fee._links.self.href)">{{ 'FEES_LINK' | translate }}</a>
$scope.load = function(url) {
$http.get(url).then(function(response) {
// show data in popup or new page.........
});
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句