We can use data-binding on input elements like this:
<input type="{{ showPassword ? 'text' : 'password' }}" name="password">
But this has similar problems as using data-binding on a href
attribute (see ngHref). This way there is an input element in the dom with the type {{ showPassword ? 'text' : 'password' }}
until angular loads. It looks convenient to have an ngType
directive much like ngHref
, what could be used this way:
<input type="password" ng-type="{{ showPassword ? 'text' : 'password' }}" name="password">
Is there any other way to do it? Do I have to implement this ngType
thing?
<input>
? A directive wrapping the two variant of the input is doable.ng-model
on the outer directive, see here for how.