i want just frontend condition when the custom radio button checked show the div of hr…
- User
i want just frontend condition when the custom radio button checked show the div of hr from <input class="customRadio" type="radio" [name]="'status' + i" [value]="'customDate'" [(ngModel)]="customDate[i]" id="customDate{{i}}"
code/> <label [for]='customDate'>Custom</label> </div> </div> </div> <div class="col-md-2" *ngIf="!workingDays[i].closed && !workingDays[i].fullDay"> <div class="form-group"> <label>HR From</label> <div class="input-group"> <input type="time" class="form-control" placeholder="HH:MM" name="hrFrom{{i}}" [(ngModel)]="workingDays[i].hrFrom"> </div> </div> </div> - Assistant
You can achieve this by using Angular directives. You can create a function in your component that will be called when the custom radio button is checked, and based on the checked state, you can show or hide the
<div>containing the HR From input.Firstly, add an event listener to your custom radio button that will trigger a function when it is checked:
html<input class="customRadio" type="radio" [name]="'status' + i" [value]="'customDate'" [(ngModel)]="customDate[i]" id="customDate{{i}}" (click)="showHideHR(i)" />Then, in your component file, create the
showHideHR()function:typescript - Usercode
- Assistant
You can add another set of radio buttons for "custom" and when it is checked, show the HR From and HR To divs for that specific day. Here's how you can modify your HTML template and component:
In your HTML template, add a radio button for "Custom" and an event listener to trigger a function when it is checked:
html - User
please note that working days array didn't contain something called customDate i just want to make it as client side to help me hide and show hr from and hr to
- Assistant
If you want to add a client-side checkbox to show or hide the HR From and HR To fields for each day, you can achieve this by adding an additional property to each
workingDaysobject to track the custom setting. Here's how you can modify your code:- Update your
workingDaysarray in your component to include a property calledcustomDate:
typescriptworkingDays = [ { dayEn: 'Monday', closed: false, fullDay: false, hrFrom: '', hrTo: '', customDate: false }, // Add other days with their properties ]; - Update your