json 对象不影响查看

json object is not effecting to view

我正在使用 angular Formio 创建动态屏幕,作为从数据库获取屏幕脚本时的一部分,如果我更改 ngOnInit() 中特定元素的标签,我可以改变。

但是一旦显示屏幕,如果我更改标签,它就不会生效。

html

<Formio [form]="form" [submission]="submission" (submit)="onSubmit($event)"></formio>
<div class="mb-5">
    <div class="row">
      <div class="col-12 mb-5">
        <div class="pull-right" style="float:right;">
          <button class="btn save-button" (click)="clearData()">Clear data</button>
          <button class="btn save-button" (click)="showData()">Show data</button>
        </div>
      </div>
    </div>
  </div>

分量

ngOnInit() {
    debugger;
    this.triggerRefresh = new EventEmitter();
    this.http.get('http://localhost:3000/angcomp/3')
    .subscribe(
      response  => {
        debugger;
        this.data = response.json();
        this.form = this.data;
        this.form.components[0].label = 'Changed';//it is updating the lable in view
      },
        err => {console.error(err)}
    ); 

}


showData() {

    this.form.components[0].label = 'Again Changed'; // here it is not changing but in this.form.components[0].label value is displaying as 'Again Changed', but not effecting in front end
}

在 formio

中尝试刷新 属性

在你HTML:

<Formio [refresh]="triggerRefresh" [form]="form" [submission]="submission" (submit)="onSubmit($event)"></formio>

在你的组件中:

showData() {
    this.form.components[0].label = 'Again Changed';
    this.triggerRefresh.emit({
    form: this.form
});
}

https://github.com/formio/angular-formio/wiki/Form-Renderer#updating-forms-and-submissions