Reputation: 251
How to define a function for a the @Input()
in an Angular component?
For example to define a method which returns a boolean value:
@Input callback:
//(allow just methods with boolean return value)
@Input callback: Function
// this is not what i prefere since it accepts all type of functions.
Upvotes: 1
Views: 280
Reputation: 1582
Create a type
.
export type MyInput = () => boolean;
@Input() callback: MyInput;
Here you can read more about Function type expressions
Upvotes: 2