DynamicDialog data passing issue

UI Components for Angular
Post Reply
jevylein
Posts: 1
Joined: 20 May 2020, 13:40

20 May 2020, 13:58

Hello all,

I'm trying to use the dynamicDialog with a child component and pass an id to it.

code from parent component:

Code: Select all

const ref = this.dS.open(ChildComponent, {
			data: {
				id: '1'
			},
			header: 'Choose a Car',
			width: '70%'
		});
the dialog opens, but i can't access the passed data

code childComponent:

Code: Select all

@Component({
  selector: 'app-child',
  templateUrl: './child.component.html',
  styleUrls: ['./child.component.css'],
  providers: [
	DynamicDialogRef,
	DynamicDialogConfig
  ]
})ChildComponent implements OnInit {
	id:string = '';

  constructor(
	public ref: DynamicDialogRef,
	public config: DynamicDialogConfig
  ) { }

  ngOnInit(): void {
	//id: this.config.id
	console.log(this.config);
  }
  
the console shows "{Promise: undefined}". With config.id there is only be shown 'undefined'.

what am I doing wrong?


Greets Jevylein

jensonzhu
Posts: 4
Joined: 05 Mar 2022, 18:56

28 Apr 2022, 18:02

Hi Jevylein,

I'm not sure you are still stucking there, I met the same problem and I found I called the component before caller give config to it, so it would be undefined. Please check the wether called component is called anywhere else like used in other .html, or in .ts as @ViewChild.

Post Reply

Return to “PrimeNG”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 22 guests