简体   繁体   English

如何通过AngularJS使用Spring Data Rest Webservices API

[英]How to consume Spring Data Rest Webservices API with AngularJS

i had been working in a Spring Rest Data API in an application (just for fun). 我一直在一个应用程序中使用Spring Rest Data API(只是为了好玩)。 I have the core made, works fine but now I want to use AngularJS as front-end. 我有核心,可以正常工作,但是现在我想使用AngularJS作为前端。 I had work with Jackson (Mapping Java Objects to JSON), but with Spring Rest Data the Json response it's diferent, it has _embedded , _links , self , etc. links that make me confuse. 我曾与Jackson合作(将Java对象映射为JSON),但是与Spring Rest Data的Json响应不同,它具有_embedded_linksself等链接,这让我感到困惑。 I have something like this in the root url http://localhost/8080/app/api/tarifas 我在根URL http://localhost/8080/app/api/tarifas 在此处输入图片说明

I have used a JS script called restangular but i have serveral problems (I'm newbie with Angular) 我使用了一个称为restangular的JS脚本,但遇到服务器问题(我是Angular的新手)

In my controller i have this 在我的控制器中,我有这个 在此处输入图片说明

Check the error 检查错误
在此处输入图片说明

If I add a RestangularProvider in my app.config(...) and change the Controller to getList instead get, works fine, but I need several entities data formats. 如果我在app.config(...)中添加RestangularProvider,然后将Controller更改为getList而不是get,则工作正常,但我需要几种实体数据格式。

在此处输入图片说明

Any help it's welcome. 欢迎任何帮助。 If you know a better way please tell me. 如果您知道更好的方法,请告诉我。 Thanks!! 谢谢!!

UPDATE I found a form to do this (i don´t know if it's the better) but now my problem is the next: I have objects that has other objects as attributes (realtionship), and the reference in the JSON is a link (not an object). UPDATE我找到了一种执行此操作的表单(我不知道它是否更好),但是现在我的问题是下一个问题:我有将其他对象作为属性(对象)的对象,并且JSON中的引用是一个链接(不是对象)。 Then, in the grid; 然后,在网格中; the value of the description's internal object is blank. 说明的内部对象的值为空白。 To get the json data I found this 为了获取json数据,我发现了这个 在此处输入图片说明

Now I have the next content for one register (one of the grid) 现在我有一个寄存器(网格之一)的下一个内容
在此处输入图片说明

And my grid (In Angular, HTML) looks like this (empty fields) 我的网格(在Angular中,HTML)看起来像这样(空字段)
在此处输入图片说明

How can I retrieve the attribute description from the member estado , categoria , etc. and show it in the grid. 如何从成员estadocategoria等中检索属性描述,并将其显示在网格中。 Should make the request to get it? 应该提出要求吗?

Thanks!! 谢谢!!

You can use either angular.toJson or json.stringify 您可以使用angular.toJson或json.stringify

Angular-toJson documentation Angular-toJson文档

Json.stringify documentation Json.Stringify文档

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM