1

I am trying to create a dynamic input fields based on a given model. I want the input elements to have a dynamic type property, but when I do it I get the following exception:

Error: type property can't be changed

I've read that IE doesn't support change of the input type, and therefore angular disallowed it for cross-browser compatibility, but I am sure there is a walkaround in my case, when the input elements are loaded only once and don't change after the first load.

The model:

        details: {
            serverName: { type: 'text' },
            port: { type: 'number' },
            nickname: { type: 'text' },
            password: { type: 'password' },
            channel: { type: 'text' },
            channelPassword: { type: 'text' },
            autoBookmarkAdd: { type: 'checkbox' }
        }

The html code:

           <ul>
                <li ng-repeat="(index,detail) in communication.details">{{index}}:
                    <input type="{{detail.type}}" ng-model="detail.value" /></li>
            </ul>
1

1 Answer 1

2

As Mark said, using ng-switch will allow me using dynamic input types.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.