M
M
mpotemkin2015-08-13 15:30:38
MongoDB
mpotemkin, 2015-08-13 15:30:38

How to make form fields dynamic in Angular JS?

Ask for help from the community. I couldn't think of it myself.
There is some application in which applications for the same type of office are created, there are categories and subcategories and form fields, usually the name, description and price are acceptable.
But you need to add the type of office in which you specify the dimensions, width, height and weight in kg. as well as the type of packaging.
Everything that I did with a simple office, everything is recorded, everything is displayed well.
But how to make it so that when choosing a category with an atypical office in the form, additional fields appear in addition to the standard ones.
Where to dig? Tell

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
makerkz, 2015-08-13
@makerkz

The question is unclear.
Store all types in JSON format, specifying the input field type, select options, etc. After that, do ng-repeat to render the dynamic form.

[{
      "type": "text",
      "model": "width"
    },
    {
      "type": "textarea",
      "model": "description"
    }]

You can also create a special directive for this, and already process the required data in it.
<dynamic-form data="data"></dynamic-form>

A
Alexey Sosnovsky, 2015-08-13
@sosnovskyas

I think it can be done in the controller. something true - standard concept, false - non-standard, and use ng-if or ng-show/ng-hide to show/hide the required fields. if i understand the problem correctly

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question