Skip to content

Instantly share code, notes, and snippets.

@DavidCabral
Created August 11, 2020 17:13
Show Gist options
  • Save DavidCabral/c914eb7f2f2468c10ec1b8ede3dec058 to your computer and use it in GitHub Desktop.
Save DavidCabral/c914eb7f2f2468c10ec1b8ede3dec058 to your computer and use it in GitHub Desktop.
<div [innerHTML]="html" >
</div>
import {Component, Input, OnInit} from '@angular/core';
import {DomSanitizer} from '@angular/platform-browser';
@Component({
selector: 'app-spacer',
templateUrl: './app-spacer.component.html',
styleUrls: ['./app-spacer.component.scss']
})
export class AppSpacerComponent implements OnInit {
@Input() totalSpace = 0;
html: any;
constructor(public sanitizer: DomSanitizer) { }
ngOnInit(): void {
let spaces = '&nbsp;';
for (let index = 1; index <= this.totalSpace - 1 ; index++) {
spaces += '&nbsp;';
}
this.html = this.sanitizer.bypassSecurityTrustHtml(spaces);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment