json对象不影响查看

我正在使用 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

}


料青山看我应如是
浏览 84回答 1
1回答

鸿蒙传说

尝试 formio 中的刷新属性在 HTML 中:<Formio [refresh]="triggerRefresh" [form]="form" [submission]="submission" (submit)="onSubmit($event)"></formio>在您的组件中:showData() {&nbsp; &nbsp; this.form.components[0].label = 'Again Changed';&nbsp; &nbsp; this.triggerRefresh.emit({&nbsp; &nbsp; form: this.form});}https://github.com/formio/angular-formio/wiki/Form-Renderer#updating-forms-and-submissions
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Html5