I am proud to introduce my latest service creation:
Service File :
InfoDetails=new BehaviorSubject<any>('');
captureServiceData(data: any): Observable<any> {
return this.http.post<any>(`${environment.url}/Info`, data)
}
In component 1:
ngOnInit(): void {
this.fetchInfo(this.UserId);
}
InfoList: any;
fetchInfo(userId)
{
this.Service.captureServiceData(json).subscribe(data => {
if (data.response == 200) {
this.InfoList = data.response;
let jsonData=[
{
"Id": 2,
"Name": "Test",
"Email": "<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="f98d9c8a8db99e94989095d79a96">[email protected]</a>",
"Code": 4346
},
{
"Id": 2,
"Name": "Test",
"Email": "<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="91e3f2e4e3a6d7f0fa76fefbb9f4f8fa">[email protected]</a>",
"Code": 4346
}
];
this.Service.InfoDetails.next(jsonData);
}
})
}
In Component 2:
let jsonData=[
{
"Id": 4,
"Name": "Test 1",
"Email": "<a href="/cdn-cgi/l/email-protection" class="__cf_email_" data-cfemail="196d7c6a6d28597e37">[email protected]</a>",
"Code": 43246
},
{
"Id": 67,
"Name": "Test 3",
"Email": "<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="74001107004747341319">[email protected]</a>",
"Code": 3336
}
];
this.ChatService.chatInfoDetails.next(jsonData);
My current challenge lies in finding a way to iterate through variables in component 2
so that any changes to the variable values are instantly reflected in the component without necessitating a page refresh.
If you have any suggestions or insights, I would greatly appreciate it. Thank you!