My component requires a Promise as an input:
export class Component {
@Input() appendingFunction: Promise<PagedData<any>>
}
The function assigned to "appendingFunction" might be structured like this:
async foo(importantParameter, parameter1,..parameter n): Promise<PagedData<City>>
Before resolving appendingFunction
, I need to set the value of importantParameter
. While I know it will be there, I'm unsure how to define it specifically. Other parameters are not relevant in this case.
How can I achieve this?
Overall structure:
External Component 1:
export class ExternalComponent1{
async foo(importantParameter, x):Promise<PagedData<boolean>>{
...
}
}
External Component 2:
export class ExternalComponent2{
async foo(importantParameter, x, y, z):Promise<PagedData<number>>{
...
}
}
HTML markup for both components:
<inner-component [appendingFunction]="foo()"></inner-component>
Inner Component:
export class InnerComponent {
@Input() appendingFunction: Promise<PagedData<any>>
onClick(){
//This is what I need
appendingFunction.setImportantParameter();
appendingFunction.then(() => doSomething)
}