Skip to content

Instantly share code, notes, and snippets.

@codebubb
Created February 16, 2018 15:31
Show Gist options
  • Select an option

  • Save codebubb/9ff713bad0110eeb47b30aee57cbd9ab to your computer and use it in GitHub Desktop.

Select an option

Save codebubb/9ff713bad0110eeb47b30aee57cbd9ab to your computer and use it in GitHub Desktop.
let pp = this.proposalForm;
let $datefields = $('.date input').datepicker(
{
format: "dd/mm/yyyy"
}
);
$datefields.on('changeDate', function (e) {
let fcn = $(this).attr('formControlName');
let index = e;
index = index.currentTarget || null;
index = index.attributes || null;
index = index['data-cpd'] || null;
if (index) { index = index.nodeValue || null; }
if (index) {
let carray = pp.controls.competitor_analysis as FormArray;
let grp = carray.controls[index] as FormGroup;
grp.controls[fcn].setValue(moment(e.date).format("DD/MM/YYYY"))
grp.controls[fcn].markAsDirty();
} else {
pp.controls[fcn].setValue(moment(e.date).format("DD/MM/YYYY"));
pp.controls[fcn].markAsDirty();
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment