I have a code like this :
var data = [
{
first_name: "Apurv",
date: "2018-01-22",
is_present: "1",
},
{
first_name: "Lucky",
date: "2018-01-22",
is_present: "0",
},
{
first_name: "Apurv",
date: "2018-01-20",
is_present: "0",
},
{
first_name: "Lucky",
date: "2018-01-20",
is_present: "1",
}
];
var groupByName = {};
data.forEach(function (a) {
groupByName [a.first_name] = groupByName [a.first_name] || [];
groupByName [a.first_name].push({ date: a.date, is_present: a.is_present });
});
console.log(groupByName);
I try to make local variable of groupByName variable become global in order to works with *ngIf on Angular 5, could everyone clearing this or maybe there is another way to solve this issue? I would be thank you before!