-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Expand file tree
/
Copy pathapp.component.ts
More file actions
31 lines (28 loc) · 826 Bytes
/
app.component.ts
File metadata and controls
31 lines (28 loc) · 826 Bytes
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
import {
ChangeDetectionStrategy,
Component,
inject,
OnInit,
} from '@angular/core';
import { MatDialog } from '@angular/material/dialog';
import { take } from 'rxjs';
import { TopicModalComponent, TopicModalData } from './topic-dialog.component';
import { TopicService } from './topic.service';
@Component({
selector: 'app-root',
template: `
<button (click)="openTopicModal()">Open Topic</button>
`,
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class AppComponent implements OnInit {
dialog = inject(MatDialog);
topicService = inject(TopicService);
ngOnInit(): void {}
openTopicModal() {
const topics$ = this.topicService.fakeGetHttpTopic().pipe(take(1));
this.dialog.open<TopicModalComponent, TopicModalData>(TopicModalComponent, {
data: { topics$ },
});
}
}