DEV Community

Faisal Ahmed
Faisal Ahmed

Posted on

Static Db Integration simple code

<div [innerHTML]="aboutUs?.description"></div>
Enter fullscreen mode Exit fullscreen mode
  • specific folder ts file
export class AboutUsComponent {
  public aboutUs: About = ABOUT_US_DB[0];

  private subReloadOne: Subscription;

  constructor(
    private _service : AboutUsService,
    private reloadService: ReloadService
  ) {}

  ngOnInit() {
    this.subReloadOne = this.reloadService.refreshData$.subscribe(async () => {
      this._getStaticData();
    });

    this._getStaticData();
  }

  private _getStaticData() {
    this.aboutUs = this._service.getAboutUs();
    console.log("aboutUs", this.aboutUs);

  }

  ngOnDestroy() {
    console.log('Page Destryed----------->');
  }
}
Enter fullscreen mode Exit fullscreen mode
  • service ts file
export class AboutUsService {
  private aboutUs: About[] = ABOUT_US_DB;

  constructor(private userService: UserService) {}

  /**
    getaboutUs()
   */

  getAboutUs() {
    let Data: About = null;
    Data = this.aboutUs?.find(
      (f: StaticDataInterface) =>
        f?.languageCulture === this.userService.getLanguageCulture()
    );
    return Data ? Data : null;
  }

}
Enter fullscreen mode Exit fullscreen mode

Heroku

Build apps, not infrastructure.

Dealing with servers, hardware, and infrastructure can take up your valuable time. Discover the benefits of Heroku, the PaaS of choice for developers since 2007.

Visit Site

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay