I have a custom footer component that should detect if i inserted one or more buttons inside, and depending on the amount of buttons inserted it should display them in a certain way, but i can't make it work properly:
app-footer-component:
export class FooterAdvancedComponent implements AfterContentInit {
public theme = input<'primary' | 'secondary'>('secondary');
public position = input<'start' | 'center' | 'end'>('start');
public multiple = false;
@ContentChildren('btn', { descendants: true }) buttons!: QueryList<any>;
public ngAfterContentInit(): void {
this.multiple = (this.buttons.length > 1);
}
}
<div class="footer-container-{{theme()}}">
<!-- Footer para múltiples botones -->
@if (multiple) {
<div class="footer-content flex justify-between">
<ng-content></ng-content>
</div>
}
<!-- Footer para un solo botón -->
@else {
<div class="footer-content flex justify-{{position()}}">
<ng-content></ng-content>
</div>
}
</div>
numeric-keyboard-component:
<app-footer-advanced>
<app-btn-arrow-back #btn (click)="onBack()" theme="secondary" label="Volver"></app-btn-arrow-back>
<app-btn-arrow-next #btn (click)="onContinue()" theme="tertiary" label="Continuar"></app-btn-arrow-next>
</app-footer-advanced>
(This should display both buttons with a justify-between, but instead i'm getting this on the html):