I\'ve been reading some articles about Angular 2 pitfalls and what to avoid, one of those things revolves around not accessing the DOM directly.
I noticed that the
To remove attributes from the DOM you provide a value of null.
To set an attribute (attribute value can be an empty string if you wish):
myrenderer.setElementAttribute(elementRef.nativeElement, 'attributename', 'attributevalue');
To remove an attribute:
myrenderer.setElementAttribute(elementRef.nativeElement, 'attributename', null);
To get an element attribute value, you have the nativeElement which you pass to setElementAttribute, so you can use that to get the attribute value using standard Javascript:
elementRef.nativeElement.getAttribute('attributename');