I have a component that takes information from a service, and I would like to use a forEach statement to initialize component's properties. This does not work:
const variables = ['records' ,'observableComplete' ]
variables.forEach(variable => {
this.user2RoleService[variable].subscribe( result => { this[variable] = result})
});
But this does work (but I should do it one by one)
const variable = 'observableComplete'
this.user2RoleService[variable].subscribe( result => { this[variable] = result})
Any thoughts how to solve it?
user2RoleService?