Created
May 23, 2022 10:26
-
-
Save hiepxanh/1306f075b2478e62133473d8cfaca537 to your computer and use it in GitHub Desktop.
angular 14 standalone lazyload angular material datepicker
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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