Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I generated a simple java REST service with netbeans and it is working and now I need to make a AngularJS controller and service to get some data (nothing special). I never used angularjs before and I probably made a mistake in the service.js because nothing is displaying in my index.html.

controller.js

angular.module('app', ['ngRoute']);
angular.module('app', ['ngResource']);

angular.module('myApp', ['ngResource'])
.factory('myService',['$resource', function ($resource) {
  return $resource('http://localhost:8080/IntelWebPlayer/webresources/ch.eiafr.iwp.backend.viewtimestamp', {}, {
    query: {method: 'GET'}
    })
  }])
  .controller('myCtrl', ['$scope','myService', function ($scope,myService) {
var b = myService.query();
alert(b);
$scope.timestamp = myService;
}]);

index.html

<!DOCTYPE html>
<html ng-app="myApp">
<head>
    <title></title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <script src="http://code.angularjs.org/1.2.3/angular.min.js"></script>
    <script src="http://code.angularjs.org/1.2.3/angular-resource.js"></script>
    <script src="js/controller.js"></script>
</head>
<body>
    <div ng-controller="myCtrl">
        {{ timestamp }}
    </div>
</body>
</html>

Can you help me or redirect me to a good tutorial ? The only thing I found was : http://draptik.github.io/blog/2013/07/13/angularjs-example-using-a-java-restful-web-service/

share|improve this question
1  
Can you show the index.html page as well? –  Davin Tryon Nov 28 '13 at 16:56
    
I just updated it –  rXp Nov 28 '13 at 20:26
add comment

1 Answer

You might try this AngularJS Step-by-Step: Services or Spring's consuming RESTful w/AngularJS. Most of these appear to be written with AngularJS 1.0 in mind, so some differences in 1.2 may come into play.

share|improve this answer
1  
Try to have the key points of the websites in your answer, incase the URL changes –  Jojodmo Feb 5 at 0:19
    
While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. –  Steinar Lima Feb 5 at 0:27
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.