As I venture into the world of AngularJS and attempt to work with a RESTful service, I am encountering a challenge.
Upon making a REST call to http://localhost:8080/application/webapi/myApp/, I receive the following JSON response:
{
"content": "Hello World",
"id": 1
}
Additionally, I have an AngularJS controller set up as follows:
var myApp = angular.module("myModule", [])
.controller("Hello", function($scope, $http) {
$http.get('http://localhost:8080/application/webapi/myApp/').
success(function(data) {
$scope.greeting = data;
});
});
My index.html file contains:
<div ng-controller="Hello">
<p>The ID is {{greeting.id}}</p>
<p>The content is {{greeting.content}}</p>
</div>
with the ng-app directive defined in the body tag.
However, upon running index.html on my Tomcat server, my REST call is not being consumed. Instead, the binding expressions are appearing blank.
The content of my index.html should display as follows:
My First Application!
The ID is 1
The content is "Hello World"
Unfortunately, this is not the case.