ngx-schema-form icon indicating copy to clipboard operation
ngx-schema-form copied to clipboard

Form doesn't update, if schema is changed in a Promise

Open Banbury opened this issue 7 years ago • 2 comments

Template <sf-form [schema]="schema" [model]="model"></sf-form> Code

async getAllContentControls() : Promise<Word.ContentControlCollection> {}

schema: any = {
    "properties": {}
}

constructor(private office: OfficeService, private zone: NgZone) { }

ngOnInit() {
    var controls = this.office.getAllContentControls().then ((controls) => {
        this.zone.run(() => {
            var schema = this.schema;
            schema.properties["Feld1"] = {"type": "string", "description": "Feld1" };
            schema.properties["Feld2"] = {"type": "string", "description": "Feld2" };
            this.schema = schema;
        });
    });
}

The form is never updated. If I remove the call to getAllContentControls the form updates alright. I have tried several combinations of async/await, too. That doesn't work either. I have removed all code from getAllContentControls. So it is not related to any other library.

Banbury avatar Aug 25 '17 07:08 Banbury

Have you tried without using zone?

ngOnInit() {
  var controls = this.office.getAllContentControls().then ((controls) => {
    var schema = this.schema;
    schema.properties["Feld1"] = {"type": "string", "description": "Feld1" };
    schema.properties["Feld2"] = {"type": "string", "description": "Feld2" };
    this.schema = schema;
  });
}

elyas-bhy avatar Aug 07 '18 15:08 elyas-bhy

I gave up on ngx-schema-form and wrote my own solution. Feel free to close this issue.

Banbury avatar Aug 07 '18 15:08 Banbury