Recent

Custom Controls Using Angular Material

Git Repo:  https://github.com/yawahang/ohcontrols Features DatePicker (Date Picker, Time Picker, Date Time Picker, and many more) RatingPicker (Vertical, Horizontal, Custom Icons) Select (Single Select, MultiSelect, Single Column, MultiColumn) Recursive Treeview

Mat Date Picker set Default value, Previous Sunday and Saturday

https://stackblitz.com/edit/ng-mat-date-value-binding-kk-12?embed=1&file=app/datepicker-value-example.html&view=preview
<mat-form-field>
  <input matInput [matDatepicker]="picker3" placeholder="Value binding" [value]="startDate.value">
  <mat-datepicker-toggle matSuffix [for]="picker3"></mat-datepicker-toggle>
  <mat-datepicker #picker3></mat-datepicker>
</mat-form-field>
<mat-form-field>
  <input matInput [matDatepicker]="picker4" placeholder="Value binding" [value]="endDate.value">
  <mat-datepicker-toggle matSuffix [for]="picker4"></mat-datepicker-toggle>
  <mat-datepicker #picker4></mat-datepicker>
</mat-form-field>
import { Component } from "@angular/core";
import { FormControl } from "@angular/forms";

/** @title Datepicker selected value */
@Component({
  selector: "datepicker-value-example",
  templateUrl: "datepicker-value-example.html",
  styleUrls: ["datepicker-value-example.css"]
})
export class DatepickerValueExample {
  today = new Date();
  sunday = new Date(
    this.today.getFullYear(),
    this.today.getMonth(),
    this.today.getDate() - this.today.getDay()
  );
  prevSunday = new Date(
    new Date(this.sunday).setDate(this.sunday.getDate() - 7)
  );
  prevSaturday = new Date(
    new Date(this.prevSunday).setDate(this.prevSunday.getDate() + 6)
  );

  startDate: any = new FormControl(this.prevSunday.toISOString());
  endDate: any = new FormControl(this.prevSaturday.toISOString());
}

Comments

Top Posts

SQL Server Symmetric Key & Certificate based Encryption With AES_256 Algorithm

Kendo Grid Angular Column Width, minResizableWidth dynamic

Kendo Grid AutoFit Columns