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

Hostinger image

Get n8n VPS hosting 3x cheaper than a cloud solution

Get fast, easy, secure n8n VPS hosting from $4.99/mo at Hostinger. Automate any workflow using a pre-installed n8n application and no-code customization.

Start now

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