AngularJS: can't change input type

后端 未结 5 2204
梦毁少年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:21

    You can't change input's type dynamically since IE disallows this and AngularJS needs to be cross-browser compatible. So even if you might see the changed type displayed in the source code AngularJS won't pick it up - type is only evaluated once and can't be changed.

    Please note that the same restriction applies to jQuery: jQuery change input type

    You only options for dynamic types are either a custom directive (where you can download a dynamic template or prepare DOM on-the-fly) or using ng-include to include include partials where the input type is a static value.

提交回复
热议问题