AngularJS $ log.debug is not a function

I am a little upset because I can’t understand what is happening with the AngularJS service $log. I don’t use it often, but I have work on another part of my site, the only reason I could think that it won’t work would be due to the block area inside the function then.
In my console, I get the following error when trying to start $log.debug:

TypeError: $log.debug is not a function
    at analysis.client.controller.js:23
    at processQueue (angular.js:14551)
    at angular.js:14567
    at Scope.$get.Scope.$eval (angular.js:15830)
    at Scope.$get.Scope.$digest (angular.js:15641)
    at angular.js:15869
    at completeOutstandingRequest (angular.js:5387)
    at angular.js:5659

Here is my analysis.client.controller.js file:

'use strict';

angular.module('analysis').controller('AnalysisController', ['$scope', '$timeout', '$mdSidenav', '$mdComponentRegistry', '$log', 'Authentication',
    function($scope, $timeout, $mdSidenav, $mdComponentRegistry, $log, Authentication) {
        $scope.user = Authentication.user;

        // Option #1
        //
        // $scope.isOpen = function() { return $mdSidenav('right').isOpen(); };
        // $scope.toggle = function() { $mdSidenav('right').toggle() };


        // Option #2 - See https://github.com/angular/material/issues/974

        $scope.toggle = angular.noop;
        $scope.isOpen = function() {
            return false;
        };

        $scope.toggleLeft = function() {
            $mdSidenav('left').toggle()
                .then(function() {
                    $log.debug('toggle left is done');
                });
        };
    }

]);

Thanks in advance for your help!

+4
source share
3 answers

, console.debug, $logProvider.

'use strict';

angular.module('analysis')
  .config(function($logProvider){
    $logProvider.debugEnabled(true);
  })
  .controller('AnalysisController', function(
    $scope,
    $timeout,
    $mdSidenav,
    $mdComponentRegistry,
    $log,
    Authentication
  ) {
    $scope.user = Authentication.user;

    // Option #1
    //
    // $scope.isOpen = function() { return $mdSidenav('right').isOpen(); };
    // $scope.toggle = function() { $mdSidenav('right').toggle() };


    // Option #2 - See https://github.com/angular/material/issues/974

    $scope.toggle = angular.noop;
    $scope.isOpen = function() {
      return false;
    };

    $scope.toggleLeft = function() {
      $mdSidenav('left').toggle().then(function() {
        $log.debug('toggle left is done');
      });
    };
  });
+5

$log debug . $log , .

app.config(function($logProvider){
  $logProvider.debugEnabled(true);
});
+4

FYI, I got the same error when I inadvertently reassigned the debugging method instead of calling it.

$log.debug = 'My log message'

Instead:

$log.debug('My log message')

After viewing the page on which there was a bad operator, I would get "TypeError: $log.debug is not a function"on other pages on which there were journal operators.

-1
source

All Articles