-
Notifications
You must be signed in to change notification settings - Fork 17
/
app.component.ts
60 lines (45 loc) · 1.72 KB
/
app.component.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import {Component, OnInit, ViewEncapsulation} from '@angular/core';
import {AngularService} from "./shared/angular.service";
import {MatDialog, MatDialogRef, MatIconRegistry} from "@angular/material";
import {DomSanitizer} from "@angular/platform-browser";
import {Subscription} from "rxjs";
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css'],
encapsulation: ViewEncapsulation.None
})
export class AppComponent implements OnInit{
isActive:boolean = false;
selectedOption: string;
hello = "Angular";
cityName :string;
subscription:Subscription;
showProgress: boolean ;
constructor(private service:AngularService , mdIconRegistry: MatIconRegistry, sanitizer: DomSanitizer
, public dialog: MatDialog){
mdIconRegistry.addSvgIcon('icon', sanitizer.bypassSecurityTrustResourceUrl('angular.svg'));
}
openDialog() {
let dialogRef = this.dialog.open(DialogResultExampleDialog);
dialogRef.afterClosed().subscribe(result => {
this.selectedOption = result;
});
}
ngOnInit() {
this.subscription = this.service.spinner$
.subscribe(item => setTimeout(() => this.showProgress = item, 0)); // work around for ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked
// this.service.incrementPageCount().then(data => this.service.changeCount(data));
}
ngOnDestroy() {
// prevent memory leak when component is destroyed
this.subscription.unsubscribe();
}
}
@Component({
selector: 'dialog-result-example-dialog',
templateUrl: './dialog-result-example-dialog.html',
})
export class DialogResultExampleDialog {
constructor(public dialogRef: MatDialogRef<DialogResultExampleDialog>) {}
}