Skip to content
This repository has been archived by the owner on Apr 30, 2018. It is now read-only.

A way to preload options in select from http but not using javascript functions directly in JSON #758

Open
falinsin opened this issue Nov 8, 2017 · 1 comment

Comments

@falinsin
Copy link

falinsin commented Nov 8, 2017

If I load this field from query to the server (examples: REST, AJAX, HTTP)

    [{
        "key": "countries",
        "type": "select",
        "className": "col-xs-6",
        "templateOptions": {
            "label": "Countries",
            "options": [
                {"name": "UK", "id":1},
                {"name": "France", "id":2},
                {"name": "Japan", "id":3}
            ],
            "valueProp": "id",
            "labelProp": "name",
            "required":true
        }
    }]

This JSON is loaded from server like a txt string and I do not want to use functions in options, only a name of a service predefined inside angular which will load the data (key-value format).

I do not know if it is possible that after resolving the promise of the load in the service the list is reflected in the options of the select.

Do you think it is better to create a new type of customize select?
And within the definition of the new type create a controller where receive the data of the default resource from where load the data.
Even it could be a simple URL wi can fill in templateOptions to make it more general and use in the controller for get the data for the options and refresh the select.

Is there an example of this?

Thanks to all the team for your brilliant work with angular-formly.

@minasvisual
Copy link

+1

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants