-
-
Notifications
You must be signed in to change notification settings - Fork 241
/
Copy pathselector-all.component.ts
74 lines (62 loc) · 1.76 KB
/
selector-all.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import {
animate,
query,
style,
transition,
trigger,
} from "@angular/animations";
import { Component, NgZone } from "@angular/core";
@Component({
moduleId: module.id,
animations: [
trigger("listAnimation", [
transition(":enter", [
query("*", [
style({ opacity: 0 }),
animate(1000, style({ opacity: 1 }))
])
]),
transition(":leave", [
query("*", [
style({ opacity: 1 }),
animate(1000, style({ opacity: 0 }))
])
])
]),
],
template: `
<FlexboxLayout flexDirection="column"
automationText="itemsContainer">
<Button text="add" automationText="add" (tap)="addRandom()"></Button>
<FlexboxLayout
flexDirection="column"
[@listAnimation]="items.length"
*ngFor="let item of items; let i=index">
<FlexboxLayout justifyContent="center" alignItems="center">
<Label [text]="'Item No.' + i"></Label>
<Button [text]="item" (tap)="remove(item)"></Button>
</FlexboxLayout>
</FlexboxLayout>
</FlexboxLayout>
`
})
export class SelectorAllComponent {
public items = [
"first",
"second",
];
constructor(private zone: NgZone) {}
add() {
const newItem = `Item ${this.items.length}`;
this.items.push(newItem);
}
addRandom() {
// this.zone.run(() => {
this.items.push('random');
// });
}
remove(item) {
const index = this.items.indexOf(item);
this.items.splice(index, 1)
}
}