I have created a input component and a datepicker component in angular. My input component creates in base of a type parameter the right input tag for text, number ecc. for the date picker i create another component that hosts a ngb-datepicker. Input component:
<div class="input-group input-group-sm">
<ng-container [ngSwitch]="type">
<ng-container *ngSwitchCase="'date'">
<app-date-picker [id]="object.id" [name]="object.id" [disabled]="disabled" (focus)="focus()" (focusout)="focusout()" [(ngModel)]="value"></app-date-picker>
</ng-container>
<div class="input-group-append" #ref>
<span *ngIf="unit" class="input-group-text" [ngClass]="{
'disabled': disabled,
'focused': focused}">{{unit}}</span>
<span class="input-group-text" [ngClass]="{'focused': focused}" *ngIf="!disabled && !readonly && !isValidationOff">
<app-quality-status #qualityStatus [objects]="[object]" [hide]="hideQualityStatus"></app-quality-status>
</span>
</div>
<div class="input-group-append" #ref>
<ng-content></ng-content>
</div>
Datepicker component:
<div class="input-group input-group-sm">
<input class="form-control" name="dp" [(ngModel)]="selectedDate" ngbDatepicker #d="ngbDatepicker" (change)="onDateChange($event.target.value)" (dateSelect)="onDateSelect($event)" [disabled]="isDisabled ? 'disabled' : null">
<div class="input-group-append">
<button class="btn btn-input calendar fa fa-calendar" (click)="d.toggle()" type="button" [disabled]="isDisabled ? 'disabled' : null"></button>
</div>
</div>
With this nested input-group div the result is that I have a control that doesn't use the whole space but only the half. If I remove the input-group in the datepicker component the problem is that my button isn't align with the text box.
How can I solve this kind of problem?
Here is my stackblitz sample https://stackblitz.com/edit/angular-pbabtg
Try adding the following css to hello.component
:host {
display: flex;
flex: auto;
}