Performance of many ng-switch alternatives in ng-repeat directives

605 Views Asked by At

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...

0

There are 0 best solutions below