I am working on an Angular web app, with a Scala backend. I have a checkbox that should automatically tick when a condition is met. The user of the app will be prompted to enter some information on another page, and when they return it should be ticked.
I have added a println
to the scala to ensure that the field is actually being updated, which is working. The .subscribe
is contained within my ngOnInit()
, but for some reason, it is not pulling the new data.
ngOnInit(): void {
this.userService.loggedInUser().subscribe( u => {
this.user = u;
this.service.getData().subscribe( data => {
if (data) {
if (data.formCompleted) {
this.formCompleted = true;
}
}
})
});
}
I will add, that when the user clicks onto another user profile, then clicks back to the one they are editing, the box is ticked correctly. So I know the data is coming back to the app, but not when I need it.
EDIT:
So I have checked the 'Network' tab in my Inspect Element on my browser, and I can see that the data is present. I just don't understand why the if()
is not being triggered. And no, it is not because of the nested subscribe()
, because the user must be logged in to view this page, and that subscribe works perfectly.