Skip to content

Commit 10f53c6

Browse files
committed
added step 49
1 parent 5d7f470 commit 10f53c6

File tree

24 files changed

+6506
-0
lines changed

24 files changed

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

step49_animations_automatic_property_calculation/app/app.component.js

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

step49_animations_automatic_property_calculation/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: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
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+
@shrinkOut="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('shrinkOut', [
58+
state('in', style({height: '*'})),
59+
transition('* => void', [
60+
style({height: '*'}),
61+
animate(250, style({height: 0}))
62+
])
63+
])
64+
]
65+
66+
67+
})
68+
export class AppComponent {
69+
heroes: Hero[];
70+
model = new Hero('');
71+
72+
constructor(){
73+
this.heroes = [
74+
new Hero('Mr. Zeeshan'),
75+
new Hero('Miss Hira'),
76+
new Hero('Mr. Inam'),
77+
new Hero('Mr. Taha'),
78+
new Hero('Mr. Rehan')
79+
];
80+
}
81+
82+
onSubmit() {
83+
console.log("form submited:" + JSON.stringify(this.model));
84+
this.heroes.push(this.model);
85+
this.model = new Hero('');
86+
}
87+
88+
deleteHero(hero: Hero){
89+
this.heroes.forEach((ele, index) => {
90+
if(ele.name === hero.name){
91+
this.heroes.splice(index, 1);
92+
console.log(index);
93+
console.log(this.heroes.length);
94+
}
95+
})
96+
97+
}
98+
99+
100+
}

step49_animations_automatic_property_calculation/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.

step49_animations_automatic_property_calculation/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+
}

step49_animations_automatic_property_calculation/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.

step49_animations_automatic_property_calculation/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)