I want to return the value from Promise then
to template function.
I'm trying to pass by making promise from subscribe and then on completing promise return the answer.
How to do that, if i return any string in template
function, it works fine
template: function (e: any) {
(function (e) {
return new Promise((resolve, reject) => {
let val: KeyValue<any> = new KeyValue<any>();
val.Key = m.field;
val.Value = e;
self.config.outGoingEvents.filter(p => p.Key == m.field)[0].Value.next(val);
self.config.inComingEvents.filter(p => p.Key == m.field)[0].Value.take(1).subscribe(m => {
resolve(m.Value);
});
}).then((resol: any) => {
debugger;
console.log(resol);
return resol;
});
})(e);
}
I have even tried a single promise and it didnt work either.
template: function (e: any) {
let a = (function() {
return new Promise((resolve, reject) => {
resolve("AAA");
})
}).bind(this);
a().then(pl => {
console.log(pl);
return pl;
});}