$ log.debug не является функцией в AngularJS - PullRequest
0 голосов
/ 19 ноября 2018

Я немного расстроен, потому что не могу понять, что происходит с сервисом журналов AngularJS $. В моей консоли я получаю следующую ошибку при попытке запустить $ log.debug

Может, кто-нибудь поможет мне, пожалуйста

angular.min.js:62 TypeError: $log.debug is not a function
    at StudentsController.js:16
    at Object.$broadcast (angular.min.js:90)
    at angular.min.js:82
    at h (angular.min.js:78)
    at h (angular.min.js:78)
    at angular.min.js:78
    at Object.$eval (angular.min.js:88)
    at Object.$digest (angular.min.js:86)
    at Object.$apply (angular.min.js:88)
    at e (angular.min.js:95)

Код:

sampleApp.controller('StudentsController', function ($scope,$rootScope, $location,studentsService,$log) {

    $rootScope.$on("$locationChangeStart", function () {
        $log.debug("$locationChangeStart fired");
    });

    $rootScope.$on("$routeChangeStart", function () {
        $log.debug("$routeChangeStart fired");
    });

    $rootScope.$on("$locationChangeSuccess", function () {
        $log.debug("$locationChangeSuccess fired");
    });

    $rootScope.$on("$routeChangeSuccess", function () {
        $log.debug("$routeChangeSuccess fired");
    });

    $scope.students = studentsService.getList();
    $scope.msg = "Hello Ramakrishna"
});

app.js

//Define an angular module for our app
var sampleApp = angular.module('sampleApp', ["ngRoute"]);
sampleApp.config(['$routeProvider','$logProvider',
    function ($routeProvider,$logProvider) {
     $logProvider.debugEnabled(true);
        $routeProvider.
            when('/Home', {
                templateUrl: 'templates/home.html',
                controller: 'HomeController'
            }).

            when('/Courses', {
                templateUrl: 'templates/courses.html',
                controller: 'CoursesController'
            }).

            when('/Students', {
                templateUrl: 'templates/students.html',
                controller: 'StudentsController'
            }).

            when('/Students/:id', {
                templateUrl: 'templates/studentsDetails.html',
                controller: 'StudentsDetailsController'
            }).

            when("/studentsSearch/:name?", {
                templateUrl: "templates/studentsSearch.html",
                controller: "StudentsSearchController"
            }).

            otherwise({
                redirectTo: '/Home'
            });

    }]);
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...