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 expose onChange/onBlur events to caller component(ie basic-example.component.) #130

Closed
rajeshpachar opened this issue Oct 1, 2016 · 5 comments

Comments

@rajeshpachar
Copy link

I am looking for ways to expose change events to caller module(ex: basic-example.component). DynamicFormCustomComponent renders itself recursively for group/array components. what would be good way to expose blur/focus event from input component to caller component in case of group/array rendering.

Thanks

@udos86
Copy link
Owner

udos86 commented Oct 1, 2016

@rajeshpachar Thanks for your contribution! That's an interesting requirement. Could please explain your use case a bit more in detail? As you may have already seen you can bind to the hasFocus property of a DynamicFormControlComponent from the outside.

@udos86 udos86 added the question label Oct 1, 2016
@rajeshpachar
Copy link
Author

Thanks for the response. I am planning to write a json wrapper component which will take json and convert it dynamic form UI. Main page has dynamic form and side bar shows suggestion for input textbox whenever text box is in focus.
dynamic form ui has nested structure, parent component -> dynamic-form-basic-control(L1) -> dynamic-form-basic-control(L2). We can't directly emit events from L2 to parent component. I believe angular2 doesn't natively support this. I was looking through web and found some proposals here:
http://stackoverflow.com/questions/34700438/global-events-in-angular-2
here 2 solutions are proposed:

  • Shared Application Model which is already supported in dynamic form through model binding
  • Shared Service. This can help to propagate any other event.

@udos86
Copy link
Owner

udos86 commented Oct 2, 2016

@rajeshpachar Alright, nice! I made a commit ccbc2db to solve your problem. You can now apply an blur and focus event binding to any DynamicFormControlComponent from the outside. All events from nested inner DynamicFormControlComponents in form arrays and form groups are also delegated to the outside.

See bootstrap.example.component.html and bootstrap.example.component.ts for usage.

Please let me know if this would help you out. If so, this will land in 1.0.4.

@rajeshpachar
Copy link
Author

@udos86 thanks for the prompt change .
This is great and I am getting events in parent component. This should help.

@udos86
Copy link
Owner

udos86 commented Oct 3, 2016

👍 Great, will be released tonight

@udos86 udos86 closed this as completed Oct 3, 2016
@udos86 udos86 added the core label Jan 29, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants