Skip to content

Instantly share code, notes, and snippets.

@hiepxanh
Created May 23, 2022 10:26
Show Gist options
  • Save hiepxanh/1306f075b2478e62133473d8cfaca537 to your computer and use it in GitHub Desktop.
Save hiepxanh/1306f075b2478e62133473d8cfaca537 to your computer and use it in GitHub Desktop.
angular 14 standalone lazyload angular material datepicker
@ViewChild('datepickerTemplate', { read: ViewContainerRef }) datepickerTemplate!: ViewContainerRef;
constructor(private fb: FormBuilder) {}
async loadComponent() {
const { DatepickerAtom } = await import('../../atoms/datepicker/datepicker.atom');
const componentRef = this.datepickerTemplate.createComponent(DatepickerAtom);
const dobControl = this.optionalForm.get('dob');
if (dobControl) {
componentRef.instance.dob = dobControl;
}
}
ngOnInit(): void {
this.loadComponent();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment