-
Notifications
You must be signed in to change notification settings - Fork 184
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't have multiple ajsf's #213
Comments
Hi, Same issue happened to me, just want to share an easy workaround until the issue is solved if both forms are not shown simultaneously. My problem was I had multiple tabs with a form in each of them and changes in one form were affected by non-showed forms in other tabs. In order to solve this I wrapped the forms in ngIf keeping track of the active tab, so each non-showed form is destroyed. Fortunately this seems to work smoothly. Hope this helps! |
That's what I did but I don't think this is a long term solution. Luckily our use-case allowed to only show one form at a time and use *ngIf for that. Still this does not feel like a proper solution..🤔 |
hi, the problem has been given since the component is sharing the same service, and when it is modified one is affected both, this is fixed by creating a new instance of the service for each child component and thus neither will be affected and both could be simultaneously without any * ngIf what I did was create a new component that inherits from JsonSchemaFormComponent You can see the complete example here https://stackblitz.com/edit/multiple-ajsf |
Hi, I'm confident that this should resolve the issue, but of course needs to be tested... |
Stale issue |
It worked for me. But I didn't provide the Token. |
Fixed starting from https://www.npmjs.com/package/@ajsf/core/v/0.5.1-beta.3, see changelog https://github.com/hamzahamidi/ajsf/releases/tag/13.1.2 |
It seems that I can not have more than one ajsf in one place. They seem to behave extremely weird, replacing eachothers form schemes and form data.
which template:
I have made a small repro here. Looks like having 2 json-schema-form in the same page either by themselves or in separate components is not supported. I can't exactly explain what the behaviour is because it seems that the data gets extremely corrupted. Either the entire scheme and data of one overrides the other or vice-versa. I have made the repo linked above as a demo. Master branch has the example with both json-schema-forms in the same
app.component
and on branchcomponentize
I have created a separate component for each json-schema form and then use it inapp.component
. It uses"@angular/core": "~9.1.4"
but originally I have bumped into this issue on"@angular/core": "~8.2.14"
.To Reproduce
Either go here, clone it,
npm install
andng serve
it to observe or just create 2 json-schema-forms in the same component, each pointing to different schemas/options/data/onChange hooks and run it.Expected behavior
I should expect to be able to have more than 1 json-schema-form pe component/page of my app.
Screenshots
If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):
Log output covering before error and any error statements
Additional context
Detailed Description
Context
It would be nice to be able to have multiple json schema forms in one place.
Possible Implementation
The text was updated successfully, but these errors were encountered: