Skip to content

Commit 9708ba1

Browse files
committed
Add Age functionality
1 parent 7ccff57 commit 9708ba1

File tree

7 files changed

+68
-7
lines changed

7 files changed

+68
-7
lines changed

src/app/age/age.component.css

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
.elder{
2+
font-size: 80px;
3+
}
4+
.normal{
5+
font-size: 40px;
6+
}
7+
.kid{
8+
color: green;
9+
}

src/app/age/age.component.html

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<div>
2+
<h1>Enter Your Age</h1>
3+
<input type="text" [(ngModel)]="age">
4+
<div>
5+
<h1 [ngClass]="{'kid': age<16 , 'normal': age > 15 && age < 60, 'elder' : age >59}">{{age}}</h1>
6+
</div>
7+
</div>

src/app/age/age.component.spec.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2+
3+
import { AgeComponent } from './age.component';
4+
5+
describe('AgeComponent', () => {
6+
let component: AgeComponent;
7+
let fixture: ComponentFixture<AgeComponent>;
8+
9+
beforeEach(async(() => {
10+
TestBed.configureTestingModule({
11+
declarations: [ AgeComponent ]
12+
})
13+
.compileComponents();
14+
}));
15+
16+
beforeEach(() => {
17+
fixture = TestBed.createComponent(AgeComponent);
18+
component = fixture.componentInstance;
19+
fixture.detectChanges();
20+
});
21+
22+
it('should create', () => {
23+
expect(component).toBeTruthy();
24+
});
25+
});

src/app/age/age.component.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { Component, OnInit } from '@angular/core';
2+
3+
@Component({
4+
selector: 'app-age',
5+
templateUrl: './age.component.html',
6+
styleUrls: ['./age.component.css']
7+
})
8+
export class AgeComponent implements OnInit {
9+
age;
10+
constructor() { }
11+
12+
ngOnInit() {
13+
}
14+
15+
}

src/app/app.component.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ <h1>Subject: Web Programming</h1>
44
<h1>Instructor: Sir Kashif Laeeq</h1>
55
</div>
66

7-
<app-calculator></app-calculator>
7+
<app-calculator></app-calculator>
8+
<app-age></app-age>

src/app/app.module.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,18 @@ import { NgModule } from '@angular/core';
33

44
import { AppComponent } from './app.component';
55
import { CalculatorComponent } from './calculator/calculator.component';
6+
import { AgeComponent } from './age/age.component';
7+
import { FormsModule } from '@angular/forms';
68

79
@NgModule({
810
declarations: [
911
AppComponent,
10-
CalculatorComponent
12+
CalculatorComponent,
13+
AgeComponent
1114
],
1215
imports: [
13-
BrowserModule
16+
BrowserModule,
17+
FormsModule
1418
],
1519
providers: [],
1620
bootstrap: [AppComponent]

src/app/calculator/calculator.component.css

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
.calculator {
22
border: 1px solid #ccc;
33
border-radius: 5px;
4-
position: absolute;
5-
top: 50%;
6-
left: 50%;
7-
transform: translate(-50%, -50%);
4+
/* position: absolute; */
5+
/* top: 50%; */
6+
/* left: 50%; */
7+
/* transform: translate(-50%, -50%); */
88
width: 400px;
99
}
1010

0 commit comments

Comments
 (0)