ngx-schema-form
ngx-schema-form copied to clipboard
Form doesn't update, if schema is changed in a Promise
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.
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;
});
}
I gave up on ngx-schema-form and wrote my own solution. Feel free to close this issue.