1

I'm getting below 2 errors while trying to open mat dialog component. All the configuration is completely used as per the guidelines. But I'm not able to solve this error.

core.mjs:6485 ERROR Error: NG0203: inject() must be called from an injection context
    at injectInjectorOnly (core.mjs:4759:1)
    at ɵɵinject (core.mjs:4769:1)
    at NodeInjectorFactory.InfoDialogComponent_Factory [as factory] (ɵfac.js? [sm]:1:1)
    at getNodeInjectable (core.mjs:3565:1)
    at instantiateRootComponent (core.mjs:10181:1)
    at createRootComponent (core.mjs:12285:1)
    at ComponentFactory.create (core.mjs:21638:1)
    at ViewContainerRef.createComponent (core.mjs:22902:1)
    at CdkPortalOutlet.attachComponentPortal (portal.mjs:535:38)
    at MatDialogContainer.attachComponentPortal (dialog.mjs:174:35)

core.mjs:6485 ERROR TypeError: Cannot read properties of undefined (reading 'focusInitialElementWhenReady')
    at MatDialogContainer._trapFocus (dialog.mjs:248:33)
    at MatDialogContainer._onAnimationDone (dialog.mjs:338:22)
    at MatDialogContainer_animation_dialogContainer_done_HostBindingHandler (dialog.mjs:371:100)
    at executeListenerWithErrorHandling (core.mjs:15019:1)
    at wrapListenerIn_markDirtyAndPreventDefault (core.mjs:15057:1)
    at animations.mjs:189:34
    at _ZoneDelegate.invoke (zone.js:372:1)
    at Object.onInvoke (core.mjs:25592:1)
    at _ZoneDelegate.invoke (zone.js:371:1)
    at Zone.run (zone.js:134:1)
  • Did you ever find a solution to this? I'm having the same error message when trying to open a dialog that contains an Angular Material Datepicker in Angular 14 – Scott-MEARN-Developer Dec 02 '22 at 11:30
  • I just solved it using this thread, but it might be different for you because mine was a problem specifically relating to the Datepicker: https://stackoverflow.com/questions/49720908/angular-material-matdatepicker-no-provider-found-for-dateadapter – Scott-MEARN-Developer Dec 02 '22 at 11:35

0 Answers0