Ngx-formly: Multiple Checkbox example

Created on 30 Mar 2017  路  3Comments  路  Source: ngx-formly/ngx-formly

I'm submitting a ...

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

Current behavior

I can't use multiple checkbox inputs.

Expected behavior

Could someone post an example of multiple checkbox?

Most helpful comment

As used in the demo:

``ts { key: 'interest', type: 'multicheckbox', templateOptions: { label: 'Interest', options: [ { key: 'sports', value: 'Sports' }, { key: 'movies', value: 'Movies' }, { key: 'others', value: 'Others' } ] } }

All 3 comments

As used in the demo:

``ts { key: 'interest', type: 'multicheckbox', templateOptions: { label: 'Interest', options: [ { key: 'sports', value: 'Sports' }, { key: 'movies', value: 'Movies' }, { key: 'others', value: 'Others' } ] } }

@franzeal can options get from server? i suffered 'RROR Error: Cannot find control with unspecified name attribute'

Options can come from a server, but you'll probably still want to provide an empty options array. Unless it's been updated recently, I believe the multicheckbox type assumes the templateOptions.options is not undefined.

Use the lifecycle hooks to update the templateOptions.options with a new array instance that you get from some asynchronous service call.

If that doesn't help, feel free to post a simple plunker and I'd be happy to take a look.

Was this page helpful?
0 / 5 - 0 ratings