Here I have tried using [(ngModel)] to render a word file but it's not working as required. Is there any other way around?
I have used Angular 10
Thanks in advance
HTML:
<div class="row">
<div class="col-12">
<ejs-documenteditorcontainer
serviceUrl="https://ej2services.syncfusion.com/production/web-services/api/documenteditor/"
style="display:block;height:660px" [enableToolbar]=true [(ngModel)]="editor"> </ejs-documenteditorcontainer>
</div>
</div>
TS:
import { Component, ViewEncapsulation } from '@angular/core';
import { ToolbarService } from '@syncfusion/ej2-angular-documenteditor';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss'],
providers: [ToolbarService]
})
export class AppComponent {
editor: any = 'www.someWordFileFromOneDriveOrFromGoogleDrive.com'
}
Document editor is not a form element. Hence it won’t support ngModel directive for binding data. It accepts only SFDT Json string. Hence you need to convert the word document to SFDT to open it in editor via open API of document editor.
https://ej2.syncfusion.com/documentation/api/document-editor#open
To open the file on load, you can use created event of document editor.
https://ej2.syncfusion.com/documentation/api/document-editor#created
Sample link to open the SFDT data in created event: https://stackblitz.com/edit/angular-7tvebw-3abz1v?file=app.component.html
For converting word documents to SFDT to load it in editor, you need server-side interaction.
Please refer the below documentation for converting word documents to SFDT in server-side.
https://ej2.syncfusion.com/angular/documentation/document-editor/import/#convert-word-documents-into-sfdt
you can also check the below documentations platform-wise on web services needed for document editor.
https://ej2.syncfusion.com/angular/documentation/document-editor/web-services/core/
https://ej2.syncfusion.com/angular/documentation/document-editor/web-services/mvc/
https://ej2.syncfusion.com/angular/documentation/document-editor/web-services/java/