-
-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathitems.component.ts
More file actions
50 lines (43 loc) · 1.64 KB
/
items.component.ts
File metadata and controls
50 lines (43 loc) · 1.64 KB
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
import { Component, OnInit, OnDestroy, NO_ERRORS_SCHEMA, inject } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { Item } from './item';
import { ItemService } from './item.service';
import { ModalComponent } from '../modal/modal.component';
import { ModalDialogService, NativeDialogService, NativeScriptCommonModule } from '@nativescript/angular';
@Component({
selector: 'ns-items',
templateUrl: './items.component.html',
imports: [NativeScriptCommonModule],
schemas: [NO_ERRORS_SCHEMA],
})
export class ItemsComponent implements OnInit, OnDestroy {
message = 'Hello Angular 20.0.0!';
items: Array<Item>;
private itemService = inject(ItemService);
private nativeDialog = inject(NativeDialogService);
private modalDialog = inject(ModalDialogService);
private http = inject(HttpClient);
ngOnInit(): void {
console.log('ItemsComponent ngOnInit');
this.items = this.itemService.getItems();
// setTimeout(() => {
// this.modalDialog.showModal(ModalComponent, {});
// // this.show1 = false;
// }, 1000);
}
openModal() {
const ref = this.nativeDialog.open(ModalComponent);
ref.afterOpened().subscribe(() => console.log('after openend'));
ref.beforeClosed().subscribe((result) => console.log('beforeClosed', result));
ref.afterClosed().subscribe((result) => console.log('afterClosed', result));
// setTimeout(() => ref.close('result!'), 1000);
}
fetchTodos() {
this.http.get(`https://jsonplaceholder.typicode.com/todos/1`).subscribe((res) => {
console.log('Http get:', res);
});
}
ngOnDestroy() {
console.log('ItemsComponent ngOnDestroy');
}
}