My controller is retrieving data from a Spring app, but it's not displaying in the form. However, when I hardcode constants into the data, it works perfectly fine.
Here is my JavaScript controller code:
sampleApp.controller('searchCourseController', ['$scope', '$http',
function($scope, $http, $routeParams, ngTableParams ) {
$scope.courses = {};
$scope.searchButton=function () {
var actionUrl = 'searchCourse';
var textToSearch = $("#txtTitle").val();
if (textToSearch.length == 0) {
alert("Please provide search criteria. Blank search is not allowed");
/* $("#loader-overlay").fadeOut();
$("#bg-loader").fadeOut(); */
return;
}
$http.get(actionUrl+"?title="+escape(textToSearch))
.success(
function(data, status, headers, config) {
$scope.courses = data;
console.log($scope.courses);
})
.error(
function(data, status, headers, config) {
});
};
$scope.editCourseButton=function () {
alert ("edit");
};
}]);
And here is the HTML I am using to display the data:
<table class="table">
<thead>
<tr>
<th>Course Name</th>
<th>Status</th>
<th class="hidden-xs">Publishing status</th>
<th class="hidden-xs">Group Name</th>
<th class="hidden-xs">Rating</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="course in $scope.courses">
<td>{{course.name}}</td>
<td>{{course.courseStatus}}</td>
<td>{{course.coursePublishStatus}}</td>
<td>{{course.courseGroupName}}</td>
<td>{{course.courseRating}}</td>
</tr>
</tbody>
</table>
It's strange that the same code works with fixed data but not with dynamic data. Any ideas on what could be causing this issue?
Thanks,