Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

219
Visualizações
TypeError: s is undefined when using Angular.js $log service

I have been given an old Angular.js app to maintain and I have been tracking an elusive bug that made me use the $log service to display a lead on the console. I used $log since the very same IDE VSC tells me that using console.log is a bad practice. Well console.log works and when I use $log.log or anything derivative out of $log it just shows: "TypeError: s is undefined", not what I was trying to display. Now I am super curious, even though I can use console.log just fine I want to know what in the world is going on. My code:

import angular from "angular";

class StuffController{

    constructor($scope,$window,usuarioService,userSession,$log,$document){
        this.$scope=$scope;
        this.$log=$log;
        this.debug;

        this.debug = function(model){
            try{
                $log.log("this is a log for: " + model);
                $log.debug("this is a debug for: " + model);
            }catch(e){
                console.log("This is a console log for: " + model +" "+ e);
            }
        }
    }
}

stuffController.$inject=["$scope","$window","usuarioService","userSession"];

angular.module("webapp").controller("StuffController",StuffController);

When I use the debug function on any ng-change I get this on the console: This is a console log for: radio TypeError: s is undefined

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda