Reputation: 3446
Is there a more clever way of retrieving template component classes than using nativeElement
reference:
this.classes= elm.nativeElement.getAttribute('class');
Which will return list of classes in string form, but I believe there is much more clever way of doing that...
Background:
I'm trying to set type
property of input type="password"
basing on ng-pristine
class without using CSS. So it's basically toggling between text
and password
basing on ng-pristine
.
Upvotes: 0
Views: 67
Reputation: 658263
This could do what you want:
<input #inp="ngForm" [type]="inp.pristine ? 'text' : 'phone'">
Upvotes: 1