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/