mdDialog as route

186 views
Skip to first unread message

Randall Meeker

unread,
Dec 27, 2016, 4:06:29 PM12/27/16
to angular-material2
Can someone show an example of using mdDialog as a route or at least retrieving ActivedRoute? I'm trying to show dynamic content, but it can not seem to see the activated route based on the examples given. 

Ng Jun Yen

unread,
Feb 4, 2017, 6:02:18 AM2/4/17
to angular-material2
You should be able to inject the router component into your dialog component and get the ActivatedRoute from there.

Randall Meeker

unread,
Feb 4, 2017, 12:13:29 PM2/4/17
to angular-material2
Yes, I agree you should. However, but it does not seem to work which is why I was looking for an example.

Ng Jun Yen

unread,
Feb 4, 2017, 6:46:14 PM2/4/17
to angular-material2
I tried injecting ActivatedRoute into my component that is being opened as a dialog and it worked. Are you getting any errors in the console?

import { Component } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { MdDialogRef } from '@angular/material/dialog';

@Component({
    selector: 'dialog',
    templateUrl: './dialog.html',
    styleUrls: ['./dialog.css']
})
export class Dialog {
    constructor(public dialogRef: MdDialogRef<Dialog>, private route: ActivatedRoute) { 
        console.log(route);
     }

    submit(): void {
        this.dialogRef.close();
    }
}
Reply all
Reply to author
Forward
0 new messages