I have a pretty unique situation of assigning value to a variable inline using click event via an async function call. I have ng-template-for where a deeply nested and complex set of object is rendered on screen(e.g. comment of comment of comment and so on). So it is not possible to take the object and assign value by key or id once the function returns.
<button (click)="c.state = callState(c) ">Check</button>
Function is as follows:
async callState(c:any){
let a = await http.call();
return Promise.all([a]);
}
Other 2 function variations return the same results:
async callState(c:any){
await http.call().then((res:any)=>{
return res.
});
}
async callState(c:any){
let a = await http.call();
return a;
}
I have tried many different variations of this, but the component view always get [object Promise]. It is supposed to pass a string. On inspection, the value is :
ZoneAwarePromise
__zone_symbol__state: true
__zone_symbol__value: [{…}]
Can someone help to assign a string from a simple http call inline on click to a view variable?
callState()
method? something like thisasync
pipe in the template was my first thought. When I try to use it within an event binding it gives the errorNo pipe found with the name ''.
StackBlitz