Please make sure to follow the IoT Forum rules & General Posting guidelines the next time you create a post in this forum.
Here is a short sample of how this could be done:
import { Component, Input } from '@angular/core';
import { ControlContainer, NgForm } from '@angular/forms';
import { DynamicComponent } from '@c8y/ngx-components';
@Component({
selector: 'sample-widget-config',
template: `
<button class="btn-primary" (click)="changeTitle()">Change title</button>
`,
viewProviders: [{ provide: ControlContainer, useExisting: NgForm }],
})
export class SampleWidgetConfigComponent implements DynamicComponent {
@Input() config = {};
private index = 0;
constructor(private ngForm: NgForm) {}
changeTitle() {
this.index++;
const title = this.ngForm.form.get('title');
title.setValue(`Incremented title ${this.index}`);
}
}