this is my service
import { Injectable } from '@angular/core';
import { GenericPostService } from 'app/shared/services/generic.post.service';
@Injectable({
providedIn: 'root'
})
export class FaqService {
constructor(
private readonly genericPostService: GenericPostService
) { }
async getFaqContent() {
return this.genericPostService.post('faq', 'getFAQContent');
}
}
this is my component
import { Location, ViewportScroller } from '@angular/common';
import { Component, OnDestroy, OnInit } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { FaqService } from '@myse/faq/faq.service';
import { Subscription } from 'rxjs';
@Component({
providers: [Location],
selector: 'myse-faq',
styleUrls: ['./faq.component.scss'],
templateUrl: './faq.component.html'
})
export class FaqComponent implements OnInit, OnDestroy {
faqSectionList: any;
subscription: Subscription;
gotoPageWithRank: any;
gotoPagedivWithRank: any;
identifylink: any;
rank: any;
divName: any;
FAQSubsectionDisplayBean = {
}
constructor(
private readonly faqservice: FaqService,
private readonly router: Router,
private readonly route: ActivatedRoute,
private readonly viewportScroller: ViewportScroller
) { }
async ngOnInit() {
this.faqSectionList = this.faqservice.getFaqContent();
}
ngOnDestroy() {
this.subscription.unsubscribe();
}
gotoPageDiv() {
window.scroll({
top: 0,
left: 0,
behavior: 'auto'
})
}
gotoPagedivwithRank(elementId: any): void {
this.viewportScroller.scrollToAnchor(elementId);
}
gotoPageDivWithURL(url) {
this.divName = String(url);
}
identifyLink(link) {
if (link == null) {
this.identifylink = null;
return this.identifyLink;
} else {
if (link.substring(0, 3) === 'faq') {
this.rank = link.substring(3);
} else {
this.identifylink = null;
return this.identifylink;
}
}
}
}
this is my template code
<div id="wrap-content-v1"
class="wrap-content">
<div class="main">
<div>
<div id="summary">
<span [innerHTML]="'tk.faq.summaryPageTitle' | translateHTML"
id="faq_title"
class="faq_title">
</span><br>
<span [innerHTML]="'tk.faq.summaryPageSubtitle' | translateHTML"
id="faq_subtitle"
class="faq_subtitle">
</span>
<br>
<br>
<div id="faqSummaryList{{faqSection.rank}}"
*ngFor="let faqSection of faqSectionList">
<div *ngIf="faqSection.summaryTitle!==null && faqSection.summaryTitle.length>0"
class="faq_textBullet"
id="faqSummaryDisplay{{faqSection.rank}}">
<font color="#B10043">
<a (click)="gotoPagedivwithRank('faqSection.rank')"
class="faq_summaryTitle"
id="faqSummary{{faqSection.rank}}"
onmouseover=""
style="cursor: pointer;">
<span id="faqSummaryValue{{faqSection.rank}}">{{faqSection.summaryTitle}}</span></a></font>
</div>
</div>
</div>
<br>
<div *ngFor="let faqSection of faqSectionList"
id=" ">
<div *ngFor="let faqSubsection of faqSection.faqSubsectionList"
id="">
<div *ngIf="faqSubsection.type==='Title'"
id="faq{{faqSection.rank}}_{{faqSubsection.rank}}_Title">
<span class="faq_title"
id="faq_subtitle">{{faqSubsection.text}}
</span><br> <br>
</div>
<div *ngIf="faqSubsection.type==='Subtitle'"
id="faq{{faqSection.rank}}_{{faqSubsection.rank}}_Subtitle">
<span class="faq_subtitle"
id="faq_subtitle">{{faqSubsection.text}}
</span><br>
<br>
</div>
<div *ngIf="faqSubsection.type==='Text'"
id="faq{{faqSection.rank}}_{{faqSubsection.rank}}_Text">
<span class="faq_text"
id="faq_text">{{faqSubsection.text}}</span><br>
</div>
<div *ngIf="faqSubsection.type==='TextWithBullet'"
id="faq{{faqSection.rank}}_{{faqSubsection.rank}}_TextWithBullet">
<span class="faq_textBullet"
id="faq_textBullet"><span class="faq_textWithBullet"
id="faq_textWithBullet">{{faqSubsection.text}}</span></span>
</div>
<div *ngIf="faqSubsection.type==='Image'"
id="faq{{faqSection.rank}}_{{faqSubsection.rank}}_Image">
<img class="faq_image"
id="faq_image"
src="faqSubsection.Image"
alt="image" /><br>
<br>
</div>
<div *ngIf="faqSubsection.type==='Link' && identifyLink(faqSubsection.linkURL)===null"
id="faq{{faqSection.rank}}_{{faqSubsection.rank}}_ExternalLink">
<font color="#B10043"><a href="{{faqSubsection.linkURL}}"
id="faq_external_link"><span class="faq_link"
id="faq_link">{{faqSubsection.text}}</span></a></font><br>
</div>
<div *ngIf="faqSubsection.type==='Link' && identifyLink(faqSubsection.linkURL)!==null"
id="faq{{faqSection.rank}}_{{faqSubsection.rank}}_InternalLink">
<font color="#B10043"><a id="gotoPageDivWithURL"
(click)="gotoPageDivWithURL(faqSubsection.linkURL)"
onmouseover=""
style="cursor: pointer;"><span class="faq_link"
id="faq_link">{{faqSubsection.text}}</span></a></font><br>
</div>
<div *ngif="faqSubsection.type==='Item'"
id="faq{{faqSection.rank}}_{{faqSubsection.rank}}_Item">
<span class="faq_itemBullet"
id="faq_itemBullet"><span class="faq_item"
id="faq_item">{{faqSubsection.text}}</span></span>
</div>
</div>
<br><br> <a (click)="gotoPageDiv()"
class="goToHomeFAQ"
id="goToHomeFAQ{{faqSection.rank}}"
onmouseover=""
style="cursor: pointer;"></a><br>
<br>
</div>
</div>
</div>
these are the codes i am not able to fetch the data can you guys please help out been struggling for days now!! I want to create an Faq page and the service call api is from a java bean....................................................................................