score:0
Accepted answer
the problem is that you're not awaiting for the http call to return the actual data.
change the method getsimulation
to look like this:
async getsimulation(id: string): promise<void> {
try {
this.currentsimulation = await this.controllerservice.get(id).topromise();
console.log('current simulation data retrieved successfully', this.currentsimulation);
} catch (error) {
console.error('error retrieving current simulation', error);
}
}
and then also do this adjustments to ngoninit()
.
async ngoninit(): promise<void> {
var id = this.route.snapshot.params['id'];
await this.getsimulation(id);
.............................
}
this should do the trick.
by the way, i don't know what version of angular you're using, that's why i used .topromise()
for casting from observable to promise. however on the recent versions of angular (iirc angular 11+), lastvaluefrom
is the one to use, since .topromise()
was deprecated and will be removed sooner than later.
so getsimulation
would ideally look like this:
async getsimulation(id: string): promise<void> {
try {
this.currentsimulation = await lastvaluefrom(this.controllerservice.get(id));
console.log('current simulation data retrieved successfully', this.currentsimulation);
} catch (error) {
console.error('error retrieving current simulation', error);
}
}
Source: stackoverflow.com
Related Query
- Problem creating chart out of GET request with Angular
- ERROR TypeError: "this.canvas is undefined" | Problem with creating a chart with angular and chart.js
- Problem for display a chart with Chart.js and Angular
- Series Details Not Showing in Angular Chart with Charts.js
- Angular chart how to show the legend data value by default along with legend name
- Redraw Chart.js Chart with Json_encoded array from ajax request
- How to get chart from data points (arrays) with inconsistent time intervals and chart.js?
- Angular Charts.js: Can't refresh chart with data
- How to use JSON data in creating a chart with chartjs?
- How can i iterate or get all object out of array with object key in Chart.js
- How to reuse a Chartjs Chart component in with different Data and get past the **Canvas is already in use** error?
- Annotation problem with ng2-charts in Angular 11
- Problem with script src for Chart.js. The CDN for Chart.js funtions fine, so my code is ok. Somehow I'm not linking the file correctly
- Angular 10 - Chart.js to draw chart in Array with convas id on runtime
- what is wrong with my code ? java script chart position
- Angular Chartjs Overlapping Bar Chart with Chartjs ver 2.7
- How to get item what been clicked on Chart (primeNg chart + angular application)
- angular 4 line chart data is not showing data from http get
- Dynamically set chart type with Angular Chart?
- Creating mixed Bar Chart with ReactJS using recharts or react-chartjs-2
- How to get data on chart based on selected date (Filtering data Chart JS with datepicker)
- ChartJS Line Chart - Points Connected out of order for Timeseries in Angular 6
- Chart.js - creating time series freqency chart with JSON data
- Cannot read properties of undefined with react-chartjs-2 and chart js problem
- How to get chart size (without labels) with chart.js?
- Angular using PrimeNG charjs problem with font colors
- Angular chart js how to use formatter with Doughnut chart
- Problem with saving data in array o Angular and Typescript
- How get values on legend label withn Chart js on Angular
- How Can I Get An Instance of a ChartJS Bar Chart Using Angular
More Query from same tag
- Chart.js - Line charts: draw points between grid lines
- vue-chartjs cannot display the labels and datasets
- Draw a single frame in Chart.js
- Time scale with single object - bar isn't centered (chart.js)
- How to add colored points with white shadow border in chart.js?
- Make overlapping d3.js radar chart elements transparent
- How can labels/legends be added for all chart types in chart.js (chartjs.org)?
- Chart.js: How to calculate the labelOffset based on the distance between ticks?
- Chart.js how to show line chart without displaying the labels on xaxis and yaxis
- Edit styles for axes in ChartJS bar chart, when gridlines are hidden
- How can I change the starting point of horizontal bars in Charts.js
- Chart.js Show Dollar Amount On Left Y And Percent Amount On Right Y
- Dynamic multiple charts in chart.js with dynamic data inside them
- Chart.js showing different graphs with select
- Chartjs not rendering in navigation stack
- Char.js - How to show labels by default in pie chart
- Dataset push in for loop only 1 time instead of 3
- ChartJs. How to stretch up line graph to the edges?
- Single Stacked bar with three sections in Angular
- Is there a way to display legend's data over the chart in chart.js?
- chart.js not working in browser with django. no error for template and static folder setting
- How to display value of only one datapoint in line chart
- Dynamically pass the JSON data in chartjs
- Horizontal bar with multiple sections in ChartJs
- how to change point style legend to diamond in chart js
- angular-chart.js tickmark issue
- Chartjs unselected lines on render
- how to always show label in chartjs without mouseover?
- Chart.js v2 formatting time labels
- How do I populate chart.js labels with array items?