DEV Community

ildefonso
ildefonso

Posted on

How to update FormGroup values in angular with developer tools.

How to update FormGroup values in angular with developer tools.

(function() {
  var el = document.querySelector('div[ng-reflect-form]'); // Form's node
  var elProbe = ng.probe(el);

  const NgControlClassReference = elProbe.providerTokens.find((p) => {
    return p.name === 'FormGroupDirective';
  });

  var directive = elProbe.injector.get(NgControlClassReference);

  var control = directive.control;

  control.setValue({
    'value1': 'test1', // FormControl
    'value2': 'test2',  // Formcontrol
  });
})();

Top comments (0)