Hi Arun,

You should read some stuff about how asynchrony works in JS. Learn about 
promises and observables and callbacks. You should really understand how 
promises work before you try stuff like this. For http calls, the 
observables mimic this behaviour very close. 
Don't ever subscribe to an observable inside a service, unless you really 
know what you are doing. Once you have this down, this is how you could 
program your onint once everything else is in place too:

class someElement {
    constructor(private userService: UserService) {}

    async ngOnInit() {
        this.user = await this.userService.getAuthentication.toPromise();
        console.log(this.user)
    }
}

But first, make sure you are understanding how callbacks and promises work.

Regards
Sander

-- 
You received this message because you are subscribed to the Google Groups 
"Angular and AngularJS discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to