MatDialog passing object in data is by reference ?

253 views
Skip to first unread message

Christophe MAILFERT

unread,
Jul 12, 2018, 11:42:49 AM7/12/18
to angular-material2
I have this code :

```
export class DialogValidateComponent implements OnInit {
...
...
sequence: Sequence;
...
constructor(
private fb: FormBuilder,
private sequenceService: SequenceService,
private dialogRef: MatDialogRef<DialogValidateComponent>,
@Inject(MAT_DIALOG_DATA) public data: any) {
this.sequence = data.sequence;
}

...
...
...

submit(): void {
...
  this.sequence.status = Sequence.STATUS_VALIDATED;
this.sequence.major_index = splittedVersion[0];
this.sequence.minor_index = splittedVersion[1];

this.dialogRef.close();
});
```

In my main component:

```
const dialogRef = this.dialog.open(DialogValidateComponent, {
data: {
sequence: this.sequence
},
width: '350px'
});

dialogRef.afterClosed().subscribe(result => {
if (result) {}
});
```

Without return anything in dialogRef.close my object has been updated in my main component.

So the question : is data object is passing by reference ?

Thx for advance.
Reply all
Reply to author
Forward
0 new messages