After trying to use the annotation @HostListener with an output the code doesn't work:
@Component(selector: 'bs-pagination',
template: '''
<li *ngFor="let page of pages" [ngClass]="{active: page['active'], disabled: disabled && !page['active']}"
class="page-item">
<a class="page-link" href (click)="selectPage(page['number'], $event)">{{page['text']}}</a>
</li>
''')
class BsPaginationComponent {
...
int _currentPage = 1;
/// gets the index of selected page
int get currentPage => _currentPage;
/// sets the index of selected page
@Input() set currentPage(num value) {
_currentPage = value ?? 1;
currentPageChange.emit(_currentPage);
}
/// emits that the current page has changed
@Output() EventEmitter currentPageChange = new EventEmitter();
@HostListener('currentPageChange', const ['\$event'])
onCurrentPageChange(currentPage) =>
pages = getPages(currentPage, totalPages);
...
}
I'll take a look tomorrow AM.
Got delayed, investigating now.
OK, I think I can reproduce. Working on fix.
EDIT: This is WAI. You can't use @HostListener to listen to yourself.
Potential fix for your code:
BsPaginationComponent() {
currentPageChange.listen(onCurrentPageChange);
}
yes, I'm already doing that thanks.
so @HostListener is not going to work anymore for self component?
Most helpful comment
I'll take a look tomorrow AM.