Skip to content
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

How to trigger method when loading formly configuration from JSON file #3894

Open
stherrienaspnet opened this issue Apr 16, 2024 · 2 comments
Labels

Comments

@stherrienaspnet
Copy link

Question

I want to use CustomButtonComponent and be able to trigger method in the PageComponent. I can trig this.print from typescript file but not when loading config from JSON file. How to acheive this?

{
type: 'button',
templateOptions: {
label: 'Click this guy',
text: 'JSON Only',
btnType: 'info',
onClick: ($event) => this.print() ,
description: 'These can have labels and stuff too if you want....',
},
}

Just imagine you are loading this stackblitz formly configuration from JSON file.

https://stackblitz.com/edit/angular-ngxformly-button-34pyo7?file=app%2Fapp.component.ts,app%2Fapp.module.ts,app%2Fbutton-type.component.ts

@DavWe
Copy link

DavWe commented Apr 18, 2024

The JSON format does not support functions as data types. I faced a similar issue, where I wanted to save a formly config with a hook function as JSON.

@stherrienaspnet
Copy link
Author

stherrienaspnet commented Apr 18, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants