Advertisement
Guest User

Untitled

a guest
Jun 15th, 2019
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. The {0} {1} {2} his {3} off
  2.  
  3. <div *ngFor="let question of questionsArray">
  4. ---- some stuff ----
  5. <div [innerHTML]="createQuestion(question)"></div>
  6. ---- some stuff ----
  7. </div>
  8.  
  9. createQuestion(question: string): SafeHtml {
  10. let innerHtml = '';
  11. let words = question.split(' ');
  12.  
  13. for (let index = 0; index < words.length; index++) {
  14. const element = words[index];
  15. if (element.indexOf('{') >= 0) {
  16. innerHtml += '<input type="text" name="test"></input>';
  17. } else {
  18. innerHtml += element;
  19. }
  20. }
  21.  
  22. return this.sanitizer.bypassSecurityTrustHtml(innerHtml);
  23. }
  24.  
  25. constructor(private sanitizer: DomSanitizer) {}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement