Is possible to change widget title Dynamically

Hi
Widget title: input change event based on I want to display the title dynamically. Could you please guide me to the Manage to name in dynamic approach?,Could you please guide to me

Hi,
Could you please help? these changes regarding?

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}`);
  }
}
1 Like

its’s working fine. Thank you so much.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.