question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot read property 'every' of undefined

See original GitHub issue

The problem is simple: When i load ranges in daterangepicker return

Cannot read property ‘every’ of undefined at DaterangepickerComponent.push

The code is

   ngOnInit() {
     AdminLTE.init();
     moment.locale("es");
     this.graph = "2";
     this.selected = {
       startDate: moment(this.start),
       endDate: moment(this.endFormat)
     };
     this.id = this.route.snapshot.paramMap.get("id");
     if (this.id) {
       this.graphCtrl.getMeter(this.id).subscribe(
         response => {
           this.ultimoValor = response["body"]["ultimoDatoConocido"];
           this.ultimoValorCierre = response["body"]["ultimoDatoCierreMes"];
           this.consumoMediaDiaria = response["body"]["consumoMedioDiario"];
           this.consumoMediaMensual = response["body"]["consumoMedioMensual"];
           this.consumoUltimoMes = response["body"]["consumoUltimoMes"];
           this.alertas = response["body"]["alarmasActivas"];
           this.contador = response["body"]["resumenDatameter"]["contador"];
           this.datameterId = response["body"]["resumenDatameter"]["id"];
           this.config();
         },
         error => {
           console.log(error);
         }
       );
     }
   }
 
   config() {
  this.ranges = {
       Hoy: [moment(), moment()],
       Ayer: [moment().subtract(1, "days"), moment().subtract(1, "days")],
       "Últimos 7 días": [moment().subtract(6, "days"), moment()],
       "Últimos 30 días": [moment().subtract(29, "days"), moment()],
       "Este mes": [moment().startOf("month"), moment().endOf("month")],
       "Mes pasado": [
         moment()
           .subtract(1, "month")
           .startOf("month"),
         moment()
           .subtract(1, "month")
           .endOf("month")
       ]
     };
 }

So: What is wrong in this code?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

4reactions
fetrarijcommented, Dec 11, 2019

This should be fixed with the latest version v2.1.10. Thanks for the stackBlitz link 😃

3reactions
musabhusainicommented, Dec 11, 2019

@fetrarij, we’re running into this issue as well. I have been able to narrow the trigger down to changing locale.customRangeLabel while showCustomRangeLabel is set to true. See this StackBlitz for a simplified example.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot read property 'every' of undefined in Angular 2 Test
I'm writing a test for my component. I'm having following error. Cannot read property 'every' of undefined. In my ...
Read more >
Uncaught TypeError: Cannot read property of undefined In
JavaScript TypeError is thrown when an operand or argument passed to a function is incompatible with the type expected by that operator or...
Read more >
Uncaught TypeError: Cannot read property 'every' of undefined
It threw this error for me. TypeError: Cannot read property 'every' of undefined at file:///C:/Users/<UN>/.atom/packages/tasks ...
Read more >
[SOLVED] Cannot Read Property of Undefined in JavaScript
The “cannot read property of undefined” error occurs when you attempt to access a property or method of a variable that is undefined...
Read more >
Fix: “Cannot Read Property of Undefined” Error in JavaScript
To fix the “cannot read property of undefined” error, use the optional chaining operator on the variable before accessing a property.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found