Skip to content

Commit ddcc114

Browse files
committed
added step 48
1 parent e6acf46 commit ddcc114

25 files changed

+6556
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules

step48_animations_entering_leaving/app/app.component.js

Lines changed: 63 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

step48_animations_entering_leaving/app/app.component.js.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
import {
2+
Component,
3+
Input,
4+
trigger,
5+
state,
6+
style,
7+
transition,
8+
animate
9+
} from '@angular/core';
10+
11+
import { Hero } from './hero';
12+
13+
@Component({
14+
moduleId: module.id,
15+
selector: 'my-app',
16+
template: `
17+
<ul class="heroes">
18+
<li *ngFor="let hero of heroes"
19+
@flyInOut="hero.state"
20+
(click)="deleteHero(hero)">
21+
{{hero.name}}
22+
</li>
23+
</ul>
24+
<form (ngSubmit)="onSubmit()">
25+
<div>
26+
<label for="name">Name</label>
27+
<input type="text" required
28+
[(ngModel)]="model.name" name="name">
29+
</div>
30+
<button type="submit">Submit</button>
31+
</form>
32+
`,
33+
34+
styles: [`
35+
.heroes {
36+
margin: 0 0 2em 0;
37+
list-style-type: none;
38+
padding: 0;
39+
width: 15em;
40+
}
41+
.heroes li {
42+
position: relative;
43+
left: 0;
44+
background-color: #EEE;
45+
margin: .5em;
46+
padding: .3em 0;
47+
height: 1.6em;
48+
border-radius: 4px;
49+
}
50+
.heroes .text {
51+
position: relative;
52+
top: -3px;
53+
}
54+
55+
`],
56+
animations: [
57+
trigger('flyInOut', [
58+
state('in', style({transform: 'translateX(0)'})),
59+
transition('void => *', [
60+
style({transform: 'translateX(-100%)'}),
61+
animate(100)
62+
]),
63+
transition('* => void', [
64+
animate(100, style({transform: 'translateX(100%)'}))
65+
])
66+
])
67+
]
68+
69+
})
70+
export class AppComponent {
71+
heroes: Hero[];
72+
model = new Hero('');
73+
74+
constructor(){
75+
this.heroes = [
76+
new Hero('Mr. Zeeshan'),
77+
new Hero('Miss Hira'),
78+
new Hero('Mr. Inam'),
79+
new Hero('Mr. Taha'),
80+
new Hero('Mr. Rehan')
81+
];
82+
}
83+
84+
onSubmit() {
85+
console.log("form submited:" + JSON.stringify(this.model));
86+
this.heroes.push(this.model);
87+
this.model = new Hero('');
88+
}
89+
90+
deleteHero(hero: Hero){
91+
this.heroes.forEach((ele, index) => {
92+
if(ele.name === hero.name){
93+
this.heroes.splice(index, 1);
94+
console.log(index);
95+
console.log(this.heroes.length);
96+
}
97+
})
98+
99+
}
100+
101+
102+
}

step48_animations_entering_leaving/app/hero.js

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

step48_animations_entering_leaving/app/hero.js.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
export class Hero {
2+
name: string;
3+
state: string;
4+
5+
constructor(name){
6+
this.name = name;
7+
this.state = "in";
8+
}
9+
10+
11+
}

step48_animations_entering_leaving/app/main.js

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

step48_animations_entering_leaving/app/main.js.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { bootstrap } from '@angular/platform-browser-dynamic';
2+
import { AppComponent } from './app.component';
3+
import { disableDeprecatedForms, provideForms } from '@angular/forms';
4+
5+
bootstrap(AppComponent, [
6+
disableDeprecatedForms(),
7+
provideForms()
8+
]);
9+
10+

0 commit comments

Comments
 (0)