In my component labeled as search-component
, the HTML snippet is displayed below:
<form class="form-horizontal form-material" (ngSubmit)="Search()" id="carsearch" [formGroup]="bookCarForm"
novalidate>
<div class="row">
<div class="col-sm search-input-align">
<input [owlDateTime]="dt1" [min]="min" [owlDateTimeTrigger]="dt1" class="form-control"
formControlName="start_datetime" placeholder="Start Date & Time">
<owl-date-time #dt1></owl-date-time>
<span class="input-group-addon"><i class="fa fa-calendar fa-search-align"></i></span>
</div>
<div class="col-sm search-input-align">
<input [owlDateTime]="dt2" [min]="min" [owlDateTimeTrigger]="dt2" class="form-control"
formControlName="end_datetime" placeholder="End Date & Time">
<owl-date-time #dt2></owl-date-time>
<span class="input-group-addon "><i class="fa fa-calendar "></i></span>
</div>
<div class="col-sm search-input-align">
<div class="toggle" (click)=toggleTextBox()>
<input type="checkbox" class="check" >
<b class="b switch"></b>
<b class="b track"></b>
</div>
<h4 id="door-delivery">Door Delivery</h4>
</div>
<div class="col-sm search-input-align address">
<div *ngIf="!visability">
<input class="form-control " formControlName="Enter_address" type="text" placeholder="Enter Address"
>
</div>
<div *ngIf="visability">
<select formControlName="p_location" class="form-control selectpicker" id="select-city" >
<option data-tokens="" disabled>
<h2>select any one </h2>
</option>
<option data-tokens="Delhi">
<h2>Hebbal</h2>
</option>
<option data-tokens="Mumbai">
<h2>Yelahanka</h2>
</option>
<option data-tokens="hyderabad">
<h2>BTM</h2>
</option>
</select>
</div>
</div>
<div class="col-sm search-input-align btn-book-now">
<button type="submit" [disabled]="bookCarForm.invalid" class="btn btn-primary align-items-center btn-align">Book
Now</button>
</div>
</div>
</form>
In the file search-component.ts
, the code snippet looks like this:
@Output() searchValues = new EventEmitter();
this.storage.set("values", this.Search.value);//storing values in local storage
this.searchValues.emit("values");
This particular search-component
can be used multiple times. Currently, I am using this form on
Page1
to select values and redirecting to page2
. On page2
, I am also utilizing
the same form. However, the challenge I'm facing is that the values selected on page1
are not carried over
to page2
despite attempting to use Event Emitter
.
I referred to a resource here,
but it did not resolve my issue. Could someone suggest the most effective approach to achieve this outcome? Your assistance would be greatly appreciated.