Before this component
was being loaded into MatDialog
but now the requirement is to load it on some url i.e. http://localhost:4200/some-url
and when I load this component via url and getting error
NullInjectorError: No provider for x!
Here is the component that I am trying to load on url.
export class MyComponent {
constructor(
public dialogRef: MatDialogRef<MyComponent>,
private fb: FormBuilder,
@Optional() @Inject(MAT_DIALOG_DATA) public data: any
) { }
}
I had component that had MatDialog
related objects that were responsible for receiving data i.e. @Optional() @Inject(MAT_DIALOG_DATA) public data: any
, something like this:
export class MyComponent {
constructor(@Optional() @Inject(MAT_DIALOG_DATA) public data: any) { }
}
Later on, with the requirement change, I had to load this component on some url instead of loading on a dialog. Just removed the dialog related data and it is done.
export class MyComponent {
constructor() { }
}