How to query Firebase (angfire) record using if-else condition

Please if someone is there to help me out on this question at stackoverflow. I have been trying alot of ways but can’t be done for me. Any help would be appreciated.

I also use this link to do, but can’t be solved:

Link to my question: