0

I can change element's attributes seamlessly like this:

<input name="{{ currentField.name }}" type="{{ currentField.properties.type }}" ... /> 

There is no problem.

But, I need to change the element (input, textarea, select etc.) dynamically.

If I try to change element, AngularJS doest not rendering the element. Instead, showing HTML:

<{{ currentField.element }} name="{{ currentField.name }}" type="{{ currentField.properties.type }}" ... /> 

Doesn't rendering the element.

This is the example {{ currentField }} data:

{ element: 'textarea', name: 'address', properties: { type: 'text', } } 

Where is the problem?

1 Answer 1

1

Use it like :

 <textarea ng-if="currentField.element == 'textarea'" name="{{ currentField.name }}" type="{{ currentField.properties.type }}" ... /> <input ng-if="currentField.element == 'input'" name="{{ currentField.name }}" type="{{ currentField.properties.type }}" ... /> 
Sign up to request clarification or add additional context in comments.

2 Comments

There are a lot of elements. Should I write this code again and again for each one?
if there lot, then then you could create a directive. here is similar question, and this demo , hope it helps

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.