I want to use tinymce editor in Angular 5 on mat-tab. But when the tab is inactive it can't load the scripts files which will required for the tinymce editor. Here is my HTML Code
<mat-tab-group>
<mat-tab label="Document Info">
<p> This is document information </p>
</mat-tab>
<mat-tab label="Add Note">
<div>
<h3 for="post-body">Editor</h3>
<text-editor [elementId]="'post-body' (onEditorKeyup)="onBody($event)">
</text-editor>
</div>
</mat-tab>
</mat-tab-group>
After spending some time testing I came up with a simple solution. Please feel free to make alterations and provide a better solution to the community as this solution is rather a quick tactical fix than solving the actual problem.
At the top of your component file, below your imports, add the following declaration:
In your class, create new properties.
Add the following function to your class. The specified tabIndex would be the tab the editor resides in. The tab indexing starts with 0 (being the first tab).
Change your mat-tab-group element to the following.
If your editor renders with a textarea inside, make sure you have some default content to load e.g.
for records that does not have a value yet.That's it.