У AngularJS есть параметры и параметры, где вы могли бы передать обратный вызов директиве (например, метод обратных вызовов AngularJS. Можно ли передать обратный вызов как @Input
для компонента Angular (что-то вроде ниже)? Если не то, что было бы самым близким к тому, что делает AngularJS?
@Component({
selector: 'suggestion-menu',
providers: [SuggestService],
template: `
<div (mousedown)="suggestionWasClicked(suggestion)">
</div>`,
changeDetection: ChangeDetectionStrategy.Default
})
export class SuggestionMenuComponent {
@Input() callback: Function;
suggestionWasClicked(clickedEntry: SomeModel): void {
this.callback(clickedEntry, this.query);
}
}
<suggestion-menu callback="insertSuggestion">
</suggestion-menu>