GroupDocs Comparison AppCompanent OnInit Metod

@Kkacar

Please check this comparison-mvc-final.zip. The following files have been updated:

  • package.json - "@groupdocs.examples.angular/comparison": "^0.8.88"
  • app.module.ts has been updated to
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';

import { AppComponent } from './app.component';
import { ComparisonModule } from "@groupdocs.examples.angular/comparison";
import { CommonModule } from '@angular/common';

import { FontAwesomeModule } from '@fortawesome/angular-fontawesome';

@NgModule({
  declarations: [AppComponent],
  imports: [BrowserModule,
    CommonModule,
    FontAwesomeModule,
    ComparisonModule
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule {}
  • app.component.ts has been updated to use AfterViewInit hook
...
  // Use AfterViewInit lifecycle hook instead of OnInit since we have to be sure
  // that the the app initialized. 
  ngAfterViewInit() {
    const firstFile = this.selectFirstDefaultFile("test.docx", '');
    const secondFile = this.selectSecondDefaultFile("test1.docx", '');

    //we need it here to notfy about the local changes
    //see more at https://blog.angular-university.io/angular-debugging/
    this.changeDetectorRef.detectChanges();

    forkJoin([firstFile, secondFile]).subscribe(() => {
      this.compare();
    });
  }
...

You can move the logic you have from ngOnViewInit to ngAfterViewInit as this function is more suitable for running the code that leads to the changes in front-end components.

Please let us know if it works as expected on your side.

@vladimir.litvinchik

Thank you for your support. As a result of your redirection, the “Compare” operation has been performed.

@Kkacar

You’re welcome. Thank you for the feedback!