'How to generate CRON expression in angular 12
We started using ngx-cron-editor library for CRON expression in angular. By default it loads with its own UI, we can hide some of the tabs respective of its options.
But we dont want to use their UI as we already have similar controls same what ngx-cron-editor provides.
This is how we are using it in our application. Defined crop options in constructor as -
public cronOptions: CronOptions = {
formInputClass: 'form-control cron-editor-input',
formSelectClass: 'form-control cron-editor-select',
formRadioClass: 'cron-editor-radio',
formCheckboxClass: 'cron-editor-checkbox',
defaultTime: '00:00:00',
hideMinutesTab: false,
hideHourlyTab: false,
hideDailyTab: false,
hideWeeklyTab: false,
hideMonthlyTab: false,
hideYearlyTab: false,
hideAdvancedTab: false,
hideSpecificWeekDayTab: false,
hideSpecificMonthWeekTab: false,
use24HourTime: false,
hideSeconds: false,
cronFlavor: 'standard'
};
Added in component as
<cron-editor #cronEditorDemo [formControl]="cronForm" [options]="cronOptions">Cron here...</cron-editor>
<b>Expression: {{cronForm.value}}</b>
This code is loading CRON editors default UI but how can we pass our own control values to it to generate CRON expression?
Our own controls values is stored in variables such as: startTime, endTime, days
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
