I have just started learning Angular 5 and I just need to open a dialog box on a button click. Application is unable to build and the error I am coming up is 'error ts2339 property dialog does not exist on type Dashboardcomponent' I have then installed angular material and cdk. It's still coming up with the same error when compiling. And the on the html page(localhost:4200), the error I am getting is 'Cannot read property 'open' of undefined'. How can I get the dialog and open working on angular?
typscript:
import { Component, OnInit } from '@angular/core';
import { WebapiService } from '../providers/webapi.service';
import { MatDialog, MatDialogRef } from '@angular/material';
import { ServerDialogComponent } from '../server-dialog/server-dialog.component';
@Component({
selector: 'app-dashboard',
templateUrl: './dashboard.component.html',
styleUrls: ['./dashboard.component.scss']
})
export class DashboardComponent implements OnInit {
constructor(private webApi: WebapiService) { }
ngOnInit() {
}
openServerDialog() {
const serverDialogRef = this.dialog.open(ServerDialogComponent, {
width: '250px',
data: { serverlist: this.webApi.getServerList() }
});
}
}
html:
<div class="main-content">
<div class="container-fluid">
<button mat-fab color="warning" (click)="openServerDialog()">open</button>
</div>
</div>