export class ApproveCabBookingComponent implements OnInit {
private errorMessage: string;
private approveBooking: ApproveBooking;
private isDataAvailable: boolean;
constructor(
private _logger: Logger,
private _router: Router,
private _routeParams: RouteParams,
private _cabBookingService: CabBookingService) {
this.isDataAvailable = false;
}
ngOnInit() {
let bookingId = this._routeParams.get('bookingId');
this._logger.log("bookingId inside ngInit = " + bookingId);
this.approveBooking = this._cabBookingService.getSingleCabBookingForApproval(bookingId)
.subscribe(
approveBooking => {
this.approveBooking = approveBooking;
this.isDataAvailable = true;
this._logger.log("this.approveBooking => " + JSON.stringify(this.approveBooking));
},
err => {
this._logger.log("Error while accessing approveBooking...error, JSONed = " + err.status + "," + JSON.stringify(err));
},
() => console.log('Approve Cab Booking Entity Fetched!');
);
}
}
The corresponding view was updated to use the 'isDataAvailable' property set in the component.
<div *ngIf="isDataAvailable">
<div class="col-md-12 title-panel">
<h3>Manage Booking </h3>
</div>
<div class="col-md-12 content-panel">
<form (ngSubmit)="onSubmit()">
<div class="row">
<div class="col-md-12">
<h4 class="label-heads">Booking ID</h4>
<div class="form-value">
<span>{{approveBooking.cabBooking.bookingId}}</span>
</div>
</div>
</div>
</form>
</div>
</div>
regards,
Karthik