Imagine having four tabs within an Angular component, each with its own set of criteria for being displayed. Here's a high-level overview of the scenario.
export class DisplayTabs {
foo: true;
bar: false;
tabs: {
'A': { order: 1, get isVisible() { return this.foo; } },
'B': { order: 2, get isVisible() { return !this.bar; } },
'C': { order: 3, get isVisible() { return this.foo && this.bar; } },
'D': { order: 4, get isVisible() { return !this.foo || this.bar; } }
};
};
The current setup encounters an issue where this
points to the tabs
object rather than the encompassing DisplayTabs object. However, the decision on displaying the tabs relies on the properties of the DisplayTabs object itself.
I have considered structuring my tabs in a more organized and maintainable manner by defining them directly inside the DisplayTabs as follows:
export class DisplayTabs {
foo: true;
bar: false;
get isTabAVisible() { return this.foo; }
get isTabBVisible() { return !this.bar; }
// etc.
Is there a way to reorganize this structure to achieve the desired outcome?