I am trying to setup a reactive variable that will update the component template from a callback. Cannot seem to figure it out. I can update the variables, and if I change the view the template shows the updates, but not before. I would like it to automatically update when data returns. Thusly…
This works fine.
export class MainUI extends MeteorComponent implements OnInit {
public username:string = ''';
public profileImage:string ='';
constructor( private router: Router) {
super();
}
ngOnInit() {
this.loadProfile();
}
loadProfile(){
Meteor.call("retrieve.profile", Meteor.userId(), (error, result)=>{
if(error){
console.log(error.toString());
} else {
console.log(result);
this.username = result.username;
this.profileImage = result.profileImage;
}
});
}
}
Template included this, which does not update when the variables do. No doubt something simple … new with this stack.
<div [hidden]="currentUser" class="logout">
<img [hidden]="profileImage==''" class="img-fluid center-block img-circle logo" src="{{profileImage}}">
<p [hidden]="username==''" class="text-md-center">{{username}}</p>
<a (click)="logout()" type="button" class="btn btn-block b-spacers text-lg-left btn-secondary"><i class="fa fa-sign-out text-lg-left"> </i> Logout</a>
</div>