Is there a way trough some method or property to postopone initialization of setGrid method of some ChildComponent in Angular?

23 views Asked by At

I have a child component:

export class PropertiesBrowseComponent implements OnInit {
public readonly GUID = 'd6f70f96-0a8d-47bc-bd73-cd942275e9b9';
@Output() public onCloseRequested = new Subject();

protected propertiesUnitsEdit: PropertiesUnitsEditComponent;

constructor(
    protected readonly propertiesLogic: PropertiesLogic,
    protected readonly modal: Modal,
    protected readonly notifier: Notifier
) {
    super(propertiesLogic);
}

public ngOnInit(): void {
    super.ngOnInit();
    this.setGrid();
} 
...

I have a call for this class in the parent class:

export class MapComponent implements OnInit, OnDestroy {
@ViewChild('propertiesBrowse', { static: true, read: PropertiesBrowseComponent })
protected propertiesBrowse: PropertiesBrowseComponent;
}

I also have logic which shows PropertiesBrowseComponent depending on some boolean parameters. The problem I'm having is that the setGrid() method (which does this.grid.setDefinition() where it collects browseList of PropertiesBrowseComponent) triggers whenever MapComponent is opened. Is there a way to somehow postpone the initial loading of the grid through some method or a property in setGrid() method?

I tried changing the @ViewChild declaration but was unsuccessful with my attempts. I also tried finding some methods to skip the initial loading of the grid but was unsuccessful with that.

0

There are 0 answers