Wednesday, 19 April 2017

Semester.getAdminSemesters is not a function

I am new to Node.js. I have a controller - "AdminController" as below-

angular.module('adminController', ['adminServices'])

.controller('adminCtrl', function($http, $location, $timeout, Semester, $scope, $routeParams) 
{
    var app = this;
function getSemesters() {
        Semester.getAdminSemesters().then(function(data) {
            if (data.data.success) {
                app.sems = data.data.sems;
            } else {
                app.errorMsg = data.data.message; // Set error message
                app.loading = false; // Stop loading icon
            }
        });
    }
    getSemesters();
});

and my adminService.js is as below:

angular.module('adminServices', [])

.factory('Semester', function($http) {
    semsFactory = {};

    semsFactory.getAdminSemesters = function() {
        return $http.get('/api/getAdminSemesters');
    }
    return semsFactory;
});

getAdminSemesters method is written in api.js file. However, when I run the code, I am getting below error.

Semester.getAdminSemesters is not a function at getSemesters (adminCtrl.js:77)

Please help, thanks in advance.



via prasaadem

No comments:

Post a Comment