Angular 2 directive to append HTML in directive selector.

I was trying creating a star rating directive for angular 5 project. It was really hard search for me to insert HTML in to directive selector.

I know an component can easily allows access to append HTML inside the element. But i needed to do this for directives as i was already using the component for product box layout.

  1. USING COMPONENT

In template:

In Class:

 

2. USING DIRECTIVE

In template.

In Class:

Now i know this directive is reusable and i am able to insert HTML dynamically through renderer2 in angular 5 project.