Hi, Thanks for your reply ! I have implemented as you suggested; but following error is coming to console -
XMLHttpRequest cannot load http://localhost:8080/demoApp/service/users <http://localhost:8080/InternetBanking_v1/service/users>. No 'Access-Control-Allow-Origin' header is present on the requested resource. I deploy my application on JBoss AS 7.1. During direct Access to GET method - I entered follwing URL which is working fine ! http://localhost:8080/demoApp/service/users Please help me how to get rid off this error ! Regards, Jayanta Pramanik On Monday, July 7, 2014 6:56:34 PM UTC+5:30, Charly Poly wrote: > > Yep, like say Eric, > > do : > > controller.js > ---------------------- > function MyAccountController($scope, $http, *UsersFactory*){ > $scope.insertData = function () { > $scope.user = {id:1, firstname: 'AA', lastName: 'CC'}; > UsersFactory.doCreateUser($scope.user); > } > > On Monday, 7 July 2014 14:37:04 UTC+2, Jayanta Pramanik wrote: >> >> Hi, >> We are creating secured web application which is using Angular-JS in web >> portal. Call to Java REST service is being made from pages. But we can not >> make the REST call successfully. Here are code snippets for the Java side >> REST service - >> >> java code:: >> >> @Path("/users") >> public class UserRestService { >> @POST >> @Consumes(MediaType.APPLICATION_JSON) >> @Produces(MediaType.APPLICATION_JSON) >> public User create(User user) { >> User user = new User(); >> return user ; >> } >> } >> >> angular js code :: >> service.js >> ----------------------- >> var consumerREST = angular.module('consumerRESTService', ['ngResource']); >> >> consumerREST.factory('UsersFactory', function ($resource) { >> var services = { >> doCreateUser : $resource('http://localhost:8080/demoApp/service/users', >> {}, { >> query: { method: 'GET', isArray: true }, >> create: { method: 'POST' } >> }) >> }; >> return services; >> }); >> >> controller.js >> ---------------------- >> function MyAccountController($scope, $http){ >> $scope.insertData = function (UsersFactory) { >> $scope.user = {id:1, firstname: 'AA', lastName: 'CC'}; >> UsersFactory.doCreateUser($scope.user); >> } >> >> Error :: Following error is found in Javascript console of the browser - >> >> Cannot read property 'doCreateUser' of undefined >> at Object.MyAccountController.$scope.removeFetchedData1 ( >> http://localhost:63342/angular-seed-master/app/js/controllers.js:358:21) >> at Object.MyAccountController.$scope.findAccountInfo ( >> http://localhost:63342/angular-seed-master/app/js/controllers.js:334:16) >> ..... >> ...... >> Please help... >> >> Thanks in advance. >> Regards >> Jayanta Pramanik >> >> -- You received this message because you are subscribed to the Google Groups "AngularJS" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/angular. For more options, visit https://groups.google.com/d/optout.
