I have an array of objects and each object has an email sender property like my sender{[email protected]}. Now I want to fill a table with 2 values: 1) name ("my sender") and 2) address ("[email protected]").
Currently I use a filter to add the 2 new properties to my object and render it with an ng-repeat. My problem now is that I get an error
[$rootScope:infdig]
(but rendering result is fine). I googled a bit and the problem may be that I create a new array in my filter and the property length not match with the ng-repeat object length.
I am new to angularjs and I am not sure if I use the filter totally wrong and there is a much bether way for my wanted solution?
Demo Code JS:
demoApp.filter("customFilter", function () {
return function (input) {
var result = [];
if (input && input.length && input.length > 0) {
for (var i = 0; i < input.length; i++) {
var senderName = "";
var senderDomain = "";
var both = input[i].Name;
both = both.split("").reverse().join("");
senderName = both.substring(both.indexOf("<") + 1).split("").reverse().join("");
senderDomain = both.substring(1, both.indexOf("<")).split("").reverse().join("");
var domainBeforeAt = senderDomain.split("@")[0];
var domainAfterAt = senderDomain.split("@")[1];
var output = {
"customId": i,
"displayName": senderName,
"domain": {
"full": senderDomain,
"beforeAt": domainBeforeAt,
"afterAt": domainAfterAt,
}
}
result.push(output);
}
}
return result;
}
});
Demo Code HTML:
<div ng-repeat="sender in list.Sender | customFilter track by $index">