I have three input fields :
All three fields are shown when the page is loaded first but when I select the value1 then address field should be shown and phone number should be hidden. Similarly when value2 is clicked phone number is shown and address is hidden.
<div class="form-group col-md-3">
<label for="age">Address</label>
<input type="text"
id="address"
class="form-control"
name="address"
placeholder="Enter the address"
[(ngModel)]="selection.address"
#address="ngModel"
[ngClass]="{ 'is-invalid': f.submitted && selectionDate.invalid }"
required
/>
<div *ngIf="f.submitted && address.invalid" class="invalid-input">
<!-- individual validation errors -->
<div *ngIf="address.errors?.required">Address is required</div>
</div>
</div>
<div class="form-group col-md-3">
<label for="age">Phone Number</label>
<input type="text"
id="phoneNumber"
class="form-control"
name="phoneNumber"
placeholder="Enter the Phone number"
[(ngModel)]="selection.phoneNumber"
#phoneNumber="ngModel"
[ngClass]="{ 'is-invalid': f.submitted && phoneNumber.invalid }"
required />
<div *ngIf="f.submitted && phoneNumber.invalid" class="invalid-input">
<!-- individual validation errors -->
<div *ngIf="phoneNumber.errors?.required">Phone Number is required</div>
</div>
</div>
</div>
<!--row 3-->
<div class="col-md-12">
<div class="form-group col-md-3">
<label for="selectionType">Selection Type</label>
<select class="form-control" id="selectionType"
[(ngModel)]="selection.selectionType" name="selectionType" required #selectionType="ngModel" [ngClass]="{ 'is-invalid': f.submitted && selectionType.invalid }">
<option value="value1">Value1</option>
<option value="value2">Value2</option>
</select>
<div *ngIf="f.submitted && selectionType.invalid" class="invalid-input">
<!-- individual validation errors -->
<div *ngIf="selectionType.errors?.required">Selection Type is required</div>
</div>
</div>
In this above original code, I tried to make changes like:
<option value="value1" (click)="callme()">Value1</option>
This is within the selection.component.ts file. I also tried to print to the console and tried to output my logic but I am not seeing any changes.
callme(){
console.log("call me");
}
How can I achieve this? Is there a new method to do it?
