-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
157 additions
and
13 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1 @@ | ||
<app-app-nav></app-app-nav> | ||
|
||
<!-- <a [routerLink]="'home'">Home</a> | ||
<a [routerLink]="'rooms'">Room</a> | ||
<a [routerLink]="'employee'">Employee</a> --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.form-group .form-control { | ||
margin-top: 5px; | ||
margin-bottom: 5px; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<form (ngSubmit)="onSubmit()" #f="ngForm" novalidate> | ||
<div class="form-group"> | ||
<label for="">Firstname</label> | ||
<input #name="ngModel" [ngClass]="{ | ||
'is-invalid': | ||
name.invalid && (name.invalid || name.touched), | ||
'is-valid': | ||
name.valid && (name.invalid || name.touched) | ||
}" minlength="1" required class="form-control" type="text" [(ngModel)]="roomModel.name" | ||
placeholder="name" name="firstName" ngModel /> | ||
<div class="invalid-feedback"> | ||
<p *ngIf="name.errors">Please fill name!</p> | ||
</div> | ||
</div> | ||
|
||
<div class="form-group"> | ||
<label for="">toISO</label> | ||
<input #isOn="ngModel" [ngClass]="{ | ||
'is-invalid': | ||
isOn.invalid && (isOn.invalid || isOn.touched), | ||
'is-valid': | ||
isOn.valid && (isOn.invalid || isOn.touched) | ||
}" minlength="1" required class="form-control" type="text" [(ngModel)]="roomModel.isOn" | ||
placeholder="isOn" name="isOn" ngModel /> | ||
<div class="invalid-feedback"> | ||
<p *ngIf="isOn.errors">Please fill isOn</p> | ||
</div> | ||
</div> | ||
|
||
<div class="form-group"> | ||
<label for="">Temparature</label> | ||
<input #temperature="ngModel" [ngClass]="{ | ||
'is-invalid': | ||
temperature.invalid && ( temperature.invalid || temperature.touched), | ||
'is-valid': | ||
temperature.valid && ( temperature.invalid || temperature.touched) | ||
}" minlength="1" required class="form-control" type="text" [(ngModel)]="roomModel.temperature" | ||
placeholder=" temperature" name=" temperature" ngModel /> | ||
<div class="invalid-feedback"> | ||
<p *ngIf="temperature.errors">Please fill temperature</p> | ||
</div> | ||
</div> | ||
|
||
<button [disabled]="f.invalid" class="btn btn-primary" type="submit" value="submit"> | ||
Submit | ||
</button> | ||
|
||
<p *ngIf="!f.invalid">{{ f.value | json }}</p> | ||
|
||
</form> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { RoomAddComponent } from './room-add.component'; | ||
|
||
describe('RoomAddComponent', () => { | ||
let component: RoomAddComponent; | ||
let fixture: ComponentFixture<RoomAddComponent>; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
declarations: [RoomAddComponent] | ||
}) | ||
.compileComponents(); | ||
|
||
fixture = TestBed.createComponent(RoomAddComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { Component, ElementRef, OnInit, ViewChild } from '@angular/core'; | ||
import { room } from '../../shared/interface/room'; | ||
|
||
@Component({ | ||
selector: 'app-room-add', | ||
templateUrl: './room-add.component.html', | ||
styleUrl: './room-add.component.css' | ||
}) | ||
export class RoomAddComponent implements OnInit{ | ||
constructor(private ref: ElementRef) { } | ||
@ViewChild('f') form: any; | ||
b: boolean = false; | ||
roomModel: room = {}; | ||
ngOnInit(): void {} | ||
|
||
onSubmit(): void { | ||
if (this.form.invalid) { | ||
alert('please enter valid data!'); | ||
return; | ||
} | ||
//pass the form object to backend via the service | ||
alert('success'); | ||
console.log(this.form.controls); | ||
|
||
//reset form value after hit the submit button | ||
this.form.reset(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters