3

Is there any frontend application sample that consumes RESTful services of Spring-data-rest backend which is written with angularJS.

Aleksander Blomskøld
  • 18,374
  • 9
  • 76
  • 82
Atıfcan Ergin
  • 138
  • 1
  • 14

4 Answers4

1

Here are some links to AngularJS apps consuming Spring RESTful services

https://github.com/spinner0815/spring-data-rest-angularjs

Mahmoud Metwally
  • 980
  • 1
  • 10
  • 24
  • Thanks MKM I will try the 1st link but the 2nd and the 3rd link that you have sent are not for spring data rest because spring data rest supports hal+json not json. – Atıfcan Ergin Mar 10 '14 at 17:59
1

My prefer for rest api for angularjs is RESTANGULAR module...

In the site you can see many examples that how they deal with Rest calls and really good documentation and good community as well...

In this example which is from spring example SPRING.IO they uses $http, but I should say that Restangular uses $http as well, so basically you can say that Restangular is extended version of $http...

and for the last you can look for $resource...

I will update my answer If I will find something new...

Poyraz Yilmaz
  • 5,847
  • 1
  • 26
  • 28
  • Ok I implemented this solution as a frontend project then I got the error of "Access-Control-Allow-Origin" even if I have added the code like: `$httpProvider.defaults.useXDomain = true; delete $httpProvider.defaults.headers.common['X-Requested-With'];` to the config – Atıfcan Ergin Mar 11 '14 at 14:07
  • I don't think this issue related with restangular, but if you can think so you can search their form to get a solution and if you can provide any code I would like to help as well... – Poyraz Yilmaz Mar 11 '14 at 14:21
  • Yeah I think It's because of the nodejs server. I have to configure it for the CORS. – Atıfcan Ergin Mar 11 '14 at 14:23
  • are you using express? – Poyraz Yilmaz Mar 11 '14 at 14:40
  • No I use netbeans' angular-seed template. It has got embedded nodejs server script. – Atıfcan Ergin Mar 11 '14 at 16:30
  • ok here creator of restngular made a plunker which is a good example what you are looking for... http://plnkr.co/edit/d6yDka?p=preview – Poyraz Yilmaz Mar 11 '14 at 17:09
  • 1
    You need to configure spring to allow cross site requests see http://stackoverflow.com/questions/22846309/cors-filter-not-working-as-intended – Gorky Jun 25 '14 at 12:57
0

At the moment, I think that angular-hal is the best library to consume Spring Data Rest output and stay with its philosophy of discovering url through relations.

The home page: https://github.com/LuvDaSun/angular-hal

and some examples :

JR Utily
  • 1,792
  • 1
  • 23
  • 38
0

here has a nice lib spring-data-rest-js can help you. It's a easy to use and lightweight javascript lib can run in both node.js and browser. After use this lib you can manage entity like this way:

let springRest = require('spring-data-rest-js');
let Student = springRest.entity.extend('students');
let student = new Student();
student.set('name', 'Tom');
//create entity
student.save().then(()=> {
    //update entity
    student.set('name', 'Physics');
    retuen student.save();
}).then(()=> {
    //delete entity
    retuen student.delete();
}).catch(err=> {
    done(err);
})

base on fetch API and Promise,inspired by Parse. It can be work with lib like AngularJS React Vue...

吴浩麟
  • 141
  • 2
  • 6