I try delete excluded types from my object. And think in should work, but I don't understand, why 'company_accountant' still in the array. And mayby you can help me and advice more elegant way to search and delete excluded types?
var data = [
{id: 1, type: "exempt_dealer"},
{id: 2, type: "licensed_dealer"},
{id: 3, type: "partnership"},
{id: 4, type: "company"},
{id: 5, type: "licensed_dealer_accountant"},
{id: 6, type: "company_accountant"},
{id: 7, type: "partnership_accountant"}
];
var exclude_types = [
'company_accountant',
'licensed_dealer_accountant',
'partnership_accountant'
];
angular.forEach(data, function (value, key) {
if(exclude_types.includes(value.type)){
data.splice(key, 1);
}
});
data should be:
data = [
{id: 1, type: "exempt_dealer"},
{id: 2, type: "licensed_dealer"},
{id: 3, type: "partnership"},
{id: 4, type: "company"}
];
but for some reason:
{id: 1, type: "exempt_dealer"},
{id: 2, type: "licensed_dealer"},
{id: 3, type: "partnership"},
{id: 4, type: "company"},
{id: 6, type: "company_accountant"}