Apply Bold functionality to a text box


#1

I am trying to set (tap)=“Bold()”; functionality to a basic editable text box, where a user can type the text and tap on the bold icon to make the text appear in bold format just like a normal text editor.

Here is a codepen example for a similar thing I am trying to achieve (this pen is in vanilla JS) : https://codepen.io/coderakki/pen/zzWjqp

I am not sure if execCommand would work with NativeScript but if there is any alternative for that, wouldn’t mind using it.

I did try with this code for Angular with NS but it is not working, how can I make the text bold just like a normal editor ?

Here is the code I am using :

ngOnInit() {
   this.editor = document.getElementById('editor')
 }  iBold() {
   document.execCommand('bold', false, null);
 }
}