Programmer
Programmer

Reputation: 95

How do I POST data from a Java REST service with angular.js

I'm using the default JEE7 REST application on Netbeans. I follow this tutorial:

https://www.youtube.com/watch?v=kFm45u1koOI

I finished this tutorial and then I tried to keep develop for my practice, first I change my databases with MySQL and work nicely.

But I can't figure out how I can POST or PUT new data on my databases. I tried to create a full CRUD apps but I can't find a good tutorial or simple for me.

Can someone help or guide on this?

Thanks.

Upvotes: 0

Views: 770

Answers (2)

eugene
eugene

Reputation: 658

You can use $http.post or $http.put from angularjs app. See the link below.

https://docs.angularjs.org/api/ng/service/$http

Upvotes: 0

S McCrohan
S McCrohan

Reputation: 6693

Here are the docs for the Angular $resource object: ngResource documentation

The example you were working with uses a $resource for a GET. Changing that to a POST just requires changing the method parameter.

There are lots of good references for using ngResource, not the least of which the official documentation. But this tutorial looks like it hits the basics and might give you some structure for getting started:

http://www.sitepoint.com/creating-crud-app-minutes-angulars-resource/

Upvotes: 1

Related Questions