2
I need to display data from a BD in a filter area but I’m not getting it, it only works if I use one of the filters, and on the console it shows the following error "Cannot read Property 'substring' of null".
Controller code:
.filter('daterangeentrevistado', function () {
return function (conversations, start_date, end_date) {
var result = [];
var start_date = start_date ? new Date(start_date.substring(start_date.length - 4, start_date.length) + "/" + start_date.substring(start_date.length - 7, start_date.length - 5) + "/" + start_date.substring(0, start_date.length == 10 ? 2 : 1)).getTime() : 0;
var end_date = end_date ? new Date(end_date.substring(end_date.length - 4, end_date.length) + "/" + end_date.substring(end_date.length - 7, end_date.length - 5) + "/" + end_date.substring(0, end_date.length == 10 ? 2 : 1)).getTime() : new Date().getTime();
if (conversations && conversations.length > 0) {
$.each(conversations, function (index, conversation) {
var conversationDate = new Date(conversation.datanascimento.substring(conversation.datanascimento.length - 4, conversation.datanascimento.length) + "/" + conversation.datanascimento.substring(conversation.datanascimento.length - 7, conversation.datanascimento.length - 5) + "/" + conversation.datanascimento.substring(0, conversation.datanascimento.length == 10 ? 2 : 1)).getTime();
if (conversationDate >= start_date && conversationDate <= end_date) {
result.push(conversation);
}
});
return result;
}
};
});
I need to get everyone in this comic book to show up even if I don’t use a filter
– Thiago Prestes
I would recommend you rename the variables
start_date
andend_date
to differentiate them from the parameters passed in the return function and prevent any kind of conflict. Then you can do a variable checkconversationDate
, apparently can also be propertyconversation.datanascimento
.– bio
How can I perform this check?? Thanks in advance!!!
– Thiago Prestes