My angular file looks like this:
angular.module('myApp', [
'ngResource',
'ngRoute',
])
// Creating our routes
.config(['$routeProvider',
function($routeProvider) {
$routeProvider
.when('/professors', {
controller : 'ProfessorListController',
templateUrl : 'static/templates/partials/professor_list.html'
})
.when('/professors/:professor_id', {
controller : 'ProfessorDetailController',
templateUrl : 'static/templates/partials/professor_detail.html'
})
.otherwise({ redirectTo : '/' });
}
])
// Getting all the professors from the API
.factory('Professor', [
'$resource', function($resource) {
return $resource('/api/professors/:id', {
id: '@id'
});
}
])
// Creating a controller containing all the professors
.controller('ProfessorListController', [
'$scope', 'Professor', function($scope, Professor) {
return $scope.professor_list = Professor.query();
}
])
// Creating a controller containing a particular professor
.controller('ProfessorDetailController', [
'$scope', '$routeParams', 'Professor',
function($scope, $routeParams, Professor) {
return $scope.professor_detail = Professor.query({
id: $routeParams.professor_id
});
}
]);
The professor list view works and is rendering data properly. However, when I go to say
/#/professors/2
its just an empty page with nothing on it. My api seems to be working since if I go to /api/professors/2, it gives me the details of the professors with id=2 as JSON.
My template professor_detail.html looks like this:
<div>
<div class="text-center" ng-repeat="prof in professor_detail">
<h3>{{prof.name}}</h3>
<p>{{prof.university}}</p>
<p>{{prof.department}}</p>
<p>{{prof.overall}}</p>
<br />
</div>
</div>
Also, in case you are wondering, I can see from my terminal that the app is finding the template (Http status 200) and also getting the data from the API (GET HTTP status 200). So what am I doing wrong?
Any help is appreciated!
Edit: Alright, when I go to #/professors/2, I get the following error in my browser error console:
Error: [$resource:badcfg] http://errors.angularjs.org/1.5.0/$resource/badcfg?p0=query&p1=array&p2=object&p3=GET&p4=%2Fapi%2Fprofessors%2F2
https://ajax.googleapis.com/ajax/libs/angularjs/1.5.0/angular.min.js:6:421
https://ajax.googleapis.com/ajax/libs/angularjs/1.5.0/angular-resource.min.js:11:51
https://ajax.googleapis.com/ajax/libs/angularjs/1.5.0/angular.min.js:126:506
$eval@https://ajax.googleapis.com/ajax/libs/angularjs/1.5.0/angular.min.js:141:47
$digest@https://ajax.googleapis.com/ajax/libs/angularjs/1.5.0/angular.min.js:138:145
$apply@https://ajax.googleapis.com/ajax/libs/angularjs/1.5.0/angular.min.js:141:348
g@https://ajax.googleapis.com/ajax/libs/angularjs/1.5.0/angular.min.js:94:145
t@https://ajax.googleapis.com/ajax/libs/angularjs/1.5.0/angular.min.js:98:261
onload@https://ajax.googleapis.com/ajax/libs/angularjs/1.5.0/angular.min.js:99:298
Any idea what this is?