I would like to add the make-col mixin defined by Bootstrap with the Angulars Renderer2.
Context
The idea is to create a directive that receives two inputs:
- The number of columns the element should use
- The total amount of columns
And adds the mixin to the element.
Code
In an ideal world it would look something like this:
@Directive({
selector: '[appCustomColumn]'
})
export class CustomColumnDirective implements OnInit {
@Input()
public amountOfColumns: number;
@Input()
public totalAmountOfColumns: number;
constructor(private elementRef: ElementRef,
private renderer: Renderer2) {
}
public ngOnInit(): void {
// This API does not exist
this.renderer.setMixin(this.elementRef.nativeElement, '@include make-col(' + this.amountOfColumns + ',' + this.totalAmountOfColumns + ')');
}
}
Question Does anyone know if you can apply a mixin through the renderer2 in Angular or if there is another way to do this?