There is a function in my code that returns an object.
public getLinkedTREsLevel() {
let result: any;
if (this.entry && this.entry.config ) {
this.entry.config.forEach( element => {
if (element.name === 'creationTIme') {
result['dateLevel'] = element?.type?.label;
}
if (element.name === 'linkedTRE') {
result['treLevel'] = element?.type?.label;
}
});
}
return result;
}
I am looking for a way to display this object in Angular without creating an additional variable.
This is how I attempted to display it, but I am getting errors indicating that treLevel
and dateLevel
are undefined:
<div class="modal-title" >{{getLinkedTREsLevel()?.treLevel}}</div>
<div class="modal-title" >{{getLinkedTREsLevel()?.dateLevel}}</div>
Is there a way to achieve this in Angular without creating any extra object or variable?