-
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.
rental details and rental service added
- Loading branch information
1 parent
9fa45bd
commit e290b34
Showing
13 changed files
with
184 additions
and
19 deletions.
There are no files selected for viewing
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,6 @@ | ||
|
||
{{rentalDetails?.title}} <br> | ||
{{rentalDetails?.subtitle}} <br> | ||
{{rentalDetails?.text}} <br> | ||
{{rentalDetails?.bedrooms}} <br> | ||
{{rentalDetails?.id}} <br> |
Empty file.
25 changes: 25 additions & 0 deletions
25
src/app/rental/rental-detail/rental-detail.component.spec.ts
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,25 @@ | ||
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { RentalDetailComponent } from './rental-detail.component'; | ||
|
||
describe('RentalDetailComponent', () => { | ||
let component: RentalDetailComponent; | ||
let fixture: ComponentFixture<RentalDetailComponent>; | ||
|
||
beforeEach(async(() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [ RentalDetailComponent ] | ||
}) | ||
.compileComponents(); | ||
})); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(RentalDetailComponent); | ||
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,32 @@ | ||
import { Component, OnInit } from '@angular/core'; | ||
import { ActivatedRoute } from "@angular/router"; | ||
import { RentalService } from "../shared/rental.service"; | ||
|
||
@Component({ | ||
selector: 'app-rental-detail', | ||
templateUrl: './rental-detail.component.html', | ||
styleUrls: ['./rental-detail.component.scss'] | ||
}) | ||
export class RentalDetailComponent implements OnInit { | ||
|
||
currentRentalId:any; | ||
rentalDetails:any; | ||
|
||
constructor(private actRoute:ActivatedRoute, | ||
private rentalService:RentalService) { } | ||
|
||
ngOnInit() { | ||
try { | ||
this.actRoute.params.subscribe((params:any)=>{ | ||
|
||
this.rentalService.getRentalById(params["id"]).subscribe((data:any)=>{ | ||
this.rentalDetails = data; | ||
console.log(data); | ||
}); | ||
}) | ||
} catch (error) { | ||
console.error(error); | ||
} | ||
} | ||
|
||
} |
18 changes: 10 additions & 8 deletions
18
src/app/rental/rental-list-item/rental-list-item.component.html
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,9 +1,11 @@ | ||
<div class="card bwm-card"> | ||
<a href="/rentals/{{rentalData?.id}}"> | ||
<div class="card bwm-card"> | ||
<img class="card-img-top" src="http://via.placeholder.com/350x250"> | ||
<div class="card-block"> | ||
<h6 class="card-subtitle">Whole Apartment</h6> | ||
<h4 class="card-title">Some Nice Apartment</h4> | ||
<p class="card-text">$170 per Night · Free Cancellation</p> | ||
<a href="#" class="card-link">More Info</a> | ||
</div> | ||
</div> | ||
<div class="card-block"> | ||
<h6 class="card-subtitle">{{rentalData?.subtitle}}</h6> | ||
<h4 class="card-title">{{rentalData?.title}}</h4> | ||
<p class="card-text">{{rentalData?.text}}</p> | ||
<a href="#" class="card-link">More Info</a> | ||
</div> | ||
</div> | ||
</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 |
---|---|---|
@@ -1 +1,4 @@ | ||
<app-rental-list></app-rental-list> | ||
<!-- <app-rental-list></app-rental-list> --> | ||
|
||
|
||
<router-outlet></router-outlet> |
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,17 +1,34 @@ | ||
import { NgModule } from "@angular/core"; | ||
import { CommonModule } from "@angular/common"; | ||
import { RouterModule, Routes } from "@angular/router"; | ||
|
||
import { RentalService } from "../rental/shared/rental.service"; | ||
|
||
import { RentalComponent } from './rental.component'; | ||
import { RentalListComponent } from './rental-list/rental-list.component'; | ||
import { RentalListItemComponent } from './rental-list-item/rental-list-item.component'; | ||
import { RentalDetailComponent } from './rental-detail/rental-detail.component'; | ||
|
||
const routes: Routes = [{ | ||
path: "rentals", | ||
component: RentalComponent, | ||
children: [ | ||
{ path: '', component: RentalListComponent }, | ||
{ path: ':id', component: RentalDetailComponent } | ||
] | ||
}] | ||
|
||
@NgModule({ | ||
declarations:[ | ||
declarations: [ | ||
RentalComponent, | ||
RentalListComponent, | ||
RentalListItemComponent | ||
RentalListItemComponent, | ||
RentalDetailComponent | ||
], | ||
imports:[], | ||
providers:[] | ||
imports: [ | ||
CommonModule, | ||
RouterModule.forChild(routes)], | ||
providers: [RentalService] | ||
}) | ||
|
||
export class RentalModule { } |
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,12 @@ | ||
import { TestBed } from '@angular/core/testing'; | ||
|
||
import { RentalService } from './rental.service'; | ||
|
||
describe('RentalService', () => { | ||
beforeEach(() => TestBed.configureTestingModule({})); | ||
|
||
it('should be created', () => { | ||
const service: RentalService = TestBed.get(RentalService); | ||
expect(service).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,53 @@ | ||
import { Injectable } from '@angular/core'; | ||
import { Observable } from "rxjs"; | ||
@Injectable() | ||
export class RentalService { | ||
|
||
constructor() { } | ||
|
||
arrRentals = [ | ||
{ "id": "0","city":"","street":"","category":"","bedrooms":"","description":"","dailyRate":"","createdAt":"","subtitle": "Whole Apartment", "title": "Some Nice Apartment", "text": "$170 per Night · Free Cancellation" }, | ||
{ "id": "1","city":"","street":"","category":"","bedrooms":"","description":"","dailyRate":"","createdAt":"","subtitle": "Whole Apartment", "title": "Some Nice Apartment", "text": "$170 per Night · Free Cancellation" }, | ||
{ "id": "2","city":"","street":"","category":"","bedrooms":"","description":"","dailyRate":"","createdAt":"","subtitle": "Whole Apartment", "title": "Some Nice Apartment", "text": "$180 per Night · Free Cancellation" }, | ||
{ "id": "3","city":"","street":"","category":"","bedrooms":"","description":"","dailyRate":"","createdAt":"","subtitle": "Whole Apartment", "title": "Some Nice Apartment", "text": "$190 per Night · Free Cancellation" }, | ||
{ "id": "4","city":"","street":"","category":"","bedrooms":"","description":"","dailyRate":"","createdAt":"","subtitle": "Whole Apartment", "title": "Some Nice Apartment", "text": "$200 per Night · Free Cancellation" }, | ||
{ "id": "5","city":"","street":"","category":"","bedrooms":"","description":"","dailyRate":"","createdAt":"","subtitle": "Whole Apartment", "title": "Some Nice Apartment", "text": "$210 per Night · Free Cancellation" }, | ||
{ "id": "6","city":"","street":"","category":"","bedrooms":"","description":"","dailyRate":"","createdAt":"","subtitle": "Whole Apartment", "title": "Some Nice Apartment", "text": "$220 per Night · Free Cancellation" } | ||
]; | ||
|
||
public getRentals() { | ||
|
||
const rentalObservable = new Observable((observer:any)=>{ | ||
setTimeout(() => { | ||
observer.next(this.arrRentals); | ||
}, 1000); | ||
|
||
setTimeout(() => { | ||
observer.error("I am a error"); | ||
}, 2000); | ||
|
||
setTimeout(() => { | ||
observer.complete(); | ||
}, 3000); | ||
}) | ||
return rentalObservable; | ||
} | ||
|
||
public getRentalById(id){ | ||
const rentalDetailsByIDObs = new Observable((observer:any)=>{ | ||
setTimeout(() => { | ||
var a = this.arrRentals[id]; | ||
observer.next(a); | ||
}, 100); | ||
setTimeout(() => { | ||
observer.error("I am a error"); | ||
}, 2000); | ||
|
||
setTimeout(() => { | ||
observer.complete(); | ||
}, 3000); | ||
}); | ||
|
||
return rentalDetailsByIDObs; | ||
} | ||
} |