So I have an Angular app with multiple components.
One of the components is a navigation bar, which consists of user and admin dropdown menus.
How do I update the main view (the body) to dynamically XHR GET
load another URL? My XHR GET code is already done with HttpClient
. <div [innerHtml]="dashboardData"></div>
doesn't work apparently.
Here is an example of my XHR code:
fetchDashboard() {
const requestOptions: object = {
// tslint:disable-next-line: max-line-length
headers: new HttpHeaders().append('Authorization', 'Bearer Tokenhere'),
responseType: 'text'
};
this.http.get<string>('http://localhost:3000/dashboard',
requestOptions)
.subscribe(response => {
console.log(response);
// this should get used to update the view
this.dashboardData = response;
}
);
}
I got recommended this but I don't know how to implement it for my use case.
Similar question, but my question needs a different solution.