0

I am trying to implement Material 2 (v2.0.0-beta.1) dialogs in my Angular 2 (v2.4.3) app.

This is my dialog component:

import { Component } from '@angular/core';
import { MdDialog, MdDialogRef } from '@angular/material';

@Component({
  selector: 'myproject-confirm',
  templateUrl: './confirm.component.html',
})
export class ConfirmDialog {

    constructor(public dialogRef: MdDialogRef<ConfirmDialog>) {}

}

And it's HTML only contains:

This is a test dialog

In the component where I want to use this dialog, I am doing this:

import { ConfirmDialog } from './confirm.component';

constructor(private _dialog: MdDialog) {}

And then I try to open the dialog like this:

let dialogRef = this._dialog.open(ConfirmDialog);

But this produces the following exception:

EXCEPTION: Cannot set property stack of [object Object] which has only a getter

I used Materials official documentation as an reference for this, and the only thing they are doing different under "Examples" there is injecting MdDialog as public instead of private. Hence, I tried changing it into public but still get the same error.

Where am I going wrong?

Glenn Utter
  • 2,313
  • 7
  • 32
  • 44

0 Answers0