Fix scoping issues while using ngIf