dimanche 12 février 2017

With AngularJS, can I use json data to generate inputs and insert into the dom?

Vote count: 0

I'm working on a custom templating system. The user selects a template, an angular $http call is made and get the information about the template. Included in that json response is the inputs needed to populate the template:

{
    "template":{
        "title": "Test Template",
        "slug": "testTemplate",
        "version": 1.0,
        "inputs":
        [
            {
                "type": "text",
                "name": "title",
                "label": "Header Title"
            },
            {
                "type": "textarea",
                "name": "intro",
                "label": "Introduction"
            }
        ]
    }
}

I'd like to use the values in each of the inputs to add that input on the page. I have to assume that I'll have no idea what inputs could be text, number, select, textarea, file, etc. I assume I need to use a directive to provide parameters to that will return the generated input then I need to add them to the page possibly as an ng-repeat.

Any help, links, or push in the right direction would be a great.

asked 39 secs ago

Let's block ads! (Why?)



With AngularJS, can I use json data to generate inputs and insert into the dom?

Aucun commentaire:

Enregistrer un commentaire