0

My problem is how can I disable button if the value of datepicker is empty. I tried checking using ngIf and get the value of that datepicker if it is empty, then disable the button, but it does not work. What I want to achieve is when the datepicker is empty button cannot be clickable or

[disabled]
. Thank you for your answer and help

Here is the code in my component.html

			
<div class="row pr-30">
  <div class="col-md-9 d-flex align-items-center">
    <span class="d-flex fw-500 mt--20">
                                    Filters:
                                </span>
    <div class="col-md-4">
      <form>
        <mat-form-field appearance="fill">
          <mat-label> From and To </mat-label>
          <mat-date-range-input [formGroup]="expiry_date" [rangePicker]="picker3">
            <input matStartDate formControlName="start" placeholder="Start date" (dateChange)="filter_date()">
            <input matEndDate formControlName="end" placeholder="End date" (dateChange)="filter_date()">
          </mat-date-range-input>
          <mat-datepicker-toggle matSuffix [for]="picker3"></mat-datepicker-toggle>
          <mat-date-range-picker #picker3></mat-date-range-picker>
          <mat-error *ngIf="expiry_date.controls.start.hasError('matStartDateInvalid')">
            Invalid start date</mat-error>
          <mat-error *ngIf="expiry_date.controls.end.hasError('matEndDateInvalid')">
            Invalid end date
          </mat-error>
        </mat-form-field>
      </form>
    </div>
  </div>
</div>

Here is the button for the download

            <div class="col-md-6 d-flex justify-content-end pr-0">
                        <div class="btn-group dropleft ">
                            <div class="btn-download" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                                <div class="d-flex align-items-center">
                                    <div class="row">
                                        <div class="col-md-2 d-flex align-items-center justify-content-start">
                                            <em class="material-icons arrow">
                                                expand_more
                                            </em>
                                        </div>
                                        <div class="col-md-10 d-flex align-items-center justify-content-center">
                                            <span>
                                                Download Reports
                                            </span>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="dropdown-menu">
                                <ul class="nav">
                                    <li class="nav-item pr-5 pl-5" style="background-color: white; border-radius: 5px;">
                                        <button class="nav-link download_buttons mt-10" (click)="export_to_pdf()" id="download_pdf">
                                            <img height="30" alt="pdf icon"
                                                src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAABmJLR0Q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7De7NaDyaM/juz0rHfn5xdafXCs8L00ULcCLBjULZ5uJUFYC9W8KrEl0thyXeC7fLztof0MO7RlfXWiGJz9XWcbHStXrtC657QNAz/8797cdm1+asQOypZgDo4oAww74xDa420lmgEa+pENR27Xr6W+pwKBxUFnB1gOz9fFhsqaVBgL/y6kulF64OWC3xrXtFqWpzaSa8pSJ9O2wpiq/nfJl+uYYqb8l0Zv7STJVC2W7qFyRSDuh0jCWL7O4cdD9ZepZY7md4G4OuDmiqBWJDCN1Y1QPMMJArhGLOk14tmoLyf8DqV3BB0bMQArDKBUd8pURdfDoTp5Av1c/a1gvTrQ09Y9lZ87WZt1d24MeOjZLOrKvjsWlhMdba2DULND+0aA77PSPbePndJ3yNKIi64uNTVwAYP/ui0lc2XSMg7Cc2/aooe+Gq7k4QD10VhiNetaIMi8Aej8uwlma+Tt8qmrUoHiQi4OuzVxEaPPvKYeW2Y2MPLIs//9mvCE1w9KVDy/38tPmlpwNmp+Z8tzXO/K3p2239/LT5ZeMU9Yr0jIAde7JKbWa1xPbdmbZ+Qbf5pa16qn/T4vUzTykb7eeGF3glKIS4BXDzRvualqGf4men8sv/qtpo/6aoYBKbN7/55Kqqzb4j4JzqZ9scUBhOnErPLdi1HyIp/xanT8wimLydTb6/2gPZZJNN1if/A3wF2OjY6OylAAAAAElFTkSuQmCC" />
                                            <span class=" ml-5 fs-12">Download to PDF</span>
                                        </button>
                                        <hr>
                                        <button class="nav-link download_buttons mb-10" (click)="export_to_xlsx()" id="download_xlsx">
                                            <img height="30" alt="pdf XLSX"
                                                src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAABmJLR0QA/wD/AP+gvaeTAAAGLklEQVR4nO2bW2hcRRjHfzNnb8nu5rba1CTbWrG69gIGpFqUVm21vopFkNIWQUsf9MUKFdFa8LH4ZBFji2LyoELrQ1/0odeoFPShQq0JFSk1F2shKclummb3XHw42e1u9nZum2zS/CBw9sucmfl/M/PNd+bswjLLLH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wWKs5ghnd/uiDud4jfkE8IgtEl4sZVqi4BLwQD5BMG/wyqvJcl9ncz6Mqk2n7EevymM7mlQq7E3dPiNwGwbIO8Eq8l/SPmLNmY94ukA2CAOeG7c+qsg7wUnxTQOQCH5ALiEmbs0AzTJH5wc5tEKy4DVZ6pLXD9rgPv4SBcZ2BWzoBCdu67G9bexL+gukP5GJB/tZoh7IOsPo8X401TZJEqyStwelhldNDKmkd1rVJVkftPYq0BM0AmJ8rZK9TGQcBAAu7QD5OEqFnZxOUn0bV3JTPBsQXVvk4fqX4yOv9JwrzjKGUTt9gpmQQzHJ5zNlWaHkInIgHMw8YuKXz200tZ/v1P42btw0aFPPUO0u1/bx/ROXiDa1gtFMZg4s3tFyAtIulhVjqGMsqZ0tEZs2ALwfSSGGeemeptp+XCoJuqeqAcmd4btEN82+hqTiUBblAsBkhfQt6gFkLrCVCwSaUhlYINkHmduG8XeRUTYQAjPSUKV6dyYmPNjeQnJg2z9oWC1KMFJmq3WOu+Sikp0G/G8m37+wm2tzgcQ9rhyHEsFCNN+baKwbBwpcWhdN+TaKdNz94yVWnnG6t+Xz64QUADhx93VEqWHYG1PqNjRfivaCsuntBPFSZAbWgnsSDh6/HrVBv4mEeHVCP4sGCA7492s93n/W7suWLP/HFJU4e/72gnBubW6o+C4xeH3NtK/iK+9BkUTk3NrcsnaTeIVVnQOeamCObrs3Qsbq5qJzXNrcUZU/Zb1q8c+Rlx5XOZ8CrRSY4CjByrXhNW2E+xY9en8hdOq2jeAkI+jA4ODei1zMCep3eW+SAZCx8KDo2lf0hkuPf4swTowj6JmPhjxa6I8sss8zi5H97Ulz2Uyp9YgAAAABJRU5ErkJggg==" />
                                            <span class=" ml-5 fs-12">Download to XLSX</span>
                                        </button>
                                    </li>
                                </ul>
                            </div>
                        </div>
                    </div>
Anonymous Asked question May 14, 2021