There is a post on Set Attribute Without value which provides a good solution using $('body').attr('data-body','');
However, in my current ionic project, I am using Angular's Renderer2 API to manipulate DOM, and I have a requirement to create a button dynamically and also to set ion-button as one of the attributes.
I am able to set the attributes which are having value with the below code, but not getting any luck in figuring out how to add the attribute without the value.
// Make Copy Button functional
this.renderer.setAttribute(code, 'id', 'copy-target');
this.renderer.addClass(button, 'copy-button');
this.renderer.setAttribute(button, 'data-clipboard-action', 'copy');
this.renderer.setAttribute(button, 'data-clipboard-target', '#copy-target');
this.renderer.setAttribute(button, 'ion-button', null); // this doesn't work.
Any guidance is appreciated.

this.renderer.setAttribute(button, 'ion-button', '');?setAttributerequiresel: any, name: string, value: string, namespace?: stringthe null must be a string. perhaps just add an empty string and see if it has the expected behavior''.'',null, and not giving any option at all. Still no luck. When I don't pass 3rd argument it comes as undefined.'Null'would be a string. Null may be used instead of a string in certain conditions tho.