AngularJS: can't change input type

后端 未结 5 2205
梦毁少年i
梦毁少年i 2020-12-06 04:40

Whenver I have an Angular expression as a value to input\'s type, it won\'t work:



        
5条回答
  •  孤城傲影
    2020-12-06 05:25

    You cannot change the input type dynamically in any browser and so it is not possible to use dynamic single input statement. You are left with using conditional statement for creation of elements where type is hard-coded.

    Use ng-switch on directive where you can compare the type and create elements based on the condition match. For example:

    In this example you are instructing angular script to compare elem.eleType using ng-switch on in second div against actual type i.e, text, password and email in the input tag (compared using ng-switch-when, and only that input element is create where the condition matches, rest will be ignored.

提交回复
热议问题