I've written a simple code snippet that's functioning as intended, but I'm looking to incorporate success and error callbacks. Here's the current code snippet:
angular
.module('studentInfoApp')
.factory('Student', Student)
.controller('StudentsController', StudentsController)
.config(config);
function config($routeProvider) {
$routeProvider
.when('/', {
controller: 'StudentsController',
templateUrl: 'app/views/student-list.html'
})
}
function Student($resource) {
return $resource('/students');
}
function StudentsController(Student, $scope, $http) {
Student.query(function(data) {
$scope.students = data;
});
}
In the function Student()
, it simply returns the resource without allowing me to specify success and error callbacks using .then
for example. Is there something obvious that I'm overlooking? Appreciate any insights you might have! Thank you!