I am using Angular 12.3 with IG 12.3.
I have a "control panel" which should show if there is data in my scenarios lists. I can verify that data has landed in both lists, but around 33% of the time, the control panel doesn't show up, even though there is data in both lists.
My UI has the following *ngIf:
scenario1List !== undefined && scenario1List !== [] && scenario1List.length > 0 && scenario2List !== undefined && scenario2List !== [] && scenario2List.length > 0
The code to load the data and fill the lists is here:
let scenarios:scenario[] = await this.scenarioService.getScenariosList(true, true).toPromise(); console.log('scenarios: ', scenarios); this.scenario1List = scenarios, this.scenario2List = scenarios;
The console log returns valid length every time, but doesn't always show the control panel. I discovered this because my Scenario dropdowns (2) were not populating and I assumed it was a timing issue, so I set them not to show unless they were going to populate (with similar *ngIf blocks) and the whole thing seems to not work as expected.
Perhaps someone could tell me what I'm doing wrong?
Hello,
Thank you for posting on our forums.
If your panel is not showing at all, it would mean that the ngIf check is not passing. My best guess would be that the part:
scenario1List !== [] is causing the issue as I am not 100% sure how angular would treat this. In JS, [] is an object, so the comparison would be object !== object and thats fine, but if scenario1list is a single item, a string per say, then the compiler will narrow both sides to numbers and here they may actually be the same thing, failing the check.
I don't have anything to test on my side, so if you can help me with some steps how to make a sample out of this, I could be able to help you more.
You are also saying that the dropdowns are not populating. Aren't there any errors if so?
Sincerely,
Tihomir TonevAssociate Software DeveloperInfragistics
In JavaScript [] is an array, {} is an object.
I figured it out, though. I have filters on both scenario lists by type, but the filter is being applied against a global instance that may not necessarily be instantiated yet.