Cannot read property 'every' of undefined
See original GitHub issueThe 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:
- Created 4 years ago
- Comments:8 (2 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This should be fixed with the latest version v2.1.10. Thanks for the stackBlitz link 😃
@fetrarij, we’re running into this issue as well. I have been able to narrow the trigger down to changing
locale.customRangeLabel
whileshowCustomRangeLabel
is set totrue
. See this StackBlitz for a simplified example.