Within my approach
private onDataLoadSuccessful(users: User[], roles: Role[]) {
this.alertService.stopLoadingMessage();
this.loadingIndicator = false;
this.dataSource.data = users.map(data => {
let newData: User;
newData = Utilities.toCamel((data));
return newData;
});
this.allRoles = roles.map(function (data) {
let newData: Role;
newData = Utilities.toCamel(data);
return newData;
});
}
I am utilizing the Utilities.toCamel(data)
function twice. Firstly, to convert the Users[]
array to camel case and secondly, on the Roles[]
array
The issue arises when it is called a second time:
this.allRoles = roles.map(function (data) {
let newData: Role;
newData = Utilities.toCamel(data);
return newData;
});
This leads to the error message:
TypeError: Cannot read property 'toCamel' of undefined
Is there something that I am overlooking? Thanks!