In my Angular project I call the method ConnectToHueBridge()
and listAllGoups()
from ngOnInit()
. It seems to me that both methods will be parallel executed. But I need to run first ConnectToHueBridge()
and then listAllGoups()
. How can I do that?
var MyHue = new huepi();
@Component({
selector: 'my-app',
template: `
<h1>Hello {{name}}</h1>
<div>
<ul>
<li *ngFor="let group of lightgroups">
{{group}}
</li>
</ul>
</div>
<Button (click)="listAllGroups()"> Get Groups</Button>`,
})
export class AppComponent {
name = 'Angular';
lightgroups: string[] = [];
constructor(){
}
ngOnInit(){
this.ConnectToHueBridge(MyHue);
this.listAllGroups();
}
listAllGroups(){
for(var g in MyHue.Groups){
this.lightgroups.push(g);
}
console.log("done loading groups");
}
ConnectToHueBridge(MyHue:any){
//do some stuff
}
}
}
If I click on the button to execute the method everything works fine. How can I execute the methods after each other?