0

I currently work on an angular directive to display a generic form, based on a json description.

I am concerned to ng-repeat over all inputs and ng-switch or ng-if-iterate on all possible input types that could be in the list. There will be about 15 types and forms can have about 20-50 inputs.

There are multiple patterns i could see myself implementing. The current POC has an input directive which ng-if switches on all types that gets called in the ng-repeat.

input-directive:

<md-input-container ng-if="description.type in ['Text', 'Number']">
    ...
</₥d-input-containter>
<md-input-container ng-if="description.type == 'Boolean'">
    ...
</₥d-input-containter>
<span ng-if="description.type == 'Select'">
    ...
</span>
...

called via:

<input description="i" ng-repeat="i in inputs"></input>

I am concerned about repeating every type for each rendered input. How well does angular manage those alternatives. How does it handle filters in the ng-repeat, e.g. if i want to filter the inputs beforehand?

Should i make different directives for all types and switch them before calling the directive? Seems to be to much overhead...

Lukas E.
  • 139
  • 1
  • 10
  • Did you ever end up finding an answer to this or testing it out yourself? – nronnei Aug 28 '17 at 15:55
  • nope, i ended up using ngIf to switch between the different input types inside the input-directive. If you come up with some more details, feel free to add them to this post! Maybe https://github.com/json-schema-form/angular-schema-form gives some hints on performant implementation in those kind of situations – Lukas E. Aug 29 '17 at 18:19
  • Thanks for your response! – nronnei Aug 30 '17 at 19:35

0 Answers0