Closed mohamedelbalshy closed 4 years ago
im new too, but i think its because the code in this.afAuth.authState.subscribe is taking time before it finishes, but in the meantime the javascript has been executed outside that scope while uid has never been assiged any value
You should consider using rxjs. Create a subject for the user identity, then use the subject.next(user.uid) to publish the value to subscribers who need it. The alternative is to move the call to getProducts inside the subscribe callback.
Here is My Product.Service which uid is undefined after i reloading the Page, but it's defined after i login in the first time, i don't know why, Please can anyone help me to discover this problem, i searched but i didn't found a solution and i asked many people but no one answer me, i'm new to Angular
Here is my Component which displays Products: