Ngx-formly: How to handle dynamic options in 'select' type

Created on 12 May 2017  路  4Comments  路  Source: ngx-formly/ngx-formly

[ ] bug report => search github for a similar issue or PR before submitting
[x] feature request
[ ] support request

Hi all!
Is there a way in ng-formly to handle dynamic options in select type?
(similar issue from angular-formly)

Most helpful comment

Certainly. This plunker demonstrates a customized select that's intended to work with objects (group capability isn't fleshed out), restore selection, and handle default values:

https://plnkr.co/edit/alOmj0wlRNffIzLGGvnr?p=preview

If all you're after is something similar to the issue you linked from angular-formly, the built in type will handle that as well. This is the above example using the select field type that is packaged with ng-formly:

https://plnkr.co/edit/P7MAFJ73KQjZEyPsgU8U?p=preview

All 4 comments

Certainly. This plunker demonstrates a customized select that's intended to work with objects (group capability isn't fleshed out), restore selection, and handle default values:

https://plnkr.co/edit/alOmj0wlRNffIzLGGvnr?p=preview

If all you're after is something similar to the issue you linked from angular-formly, the built in type will handle that as well. This is the above example using the select field type that is packaged with ng-formly:

https://plnkr.co/edit/P7MAFJ73KQjZEyPsgU8U?p=preview

Thanks for these examples. Is there a way to use arrow function instead of onInit: function() {...} and still get the access to to.options param?

Not that I'm aware of.

This is the answer for my last question I believe :)
https://github.com/formly-js/ng-formly/blob/master/demo/src/app.component.ts#L171

Was this page helpful?
0 / 5 - 0 ratings