Accepted answer

Another approach is that you can get the data before the template loads using angular routeProvider parameter resolve.

Get the initial data

resolve: {
    initialData: function(newsControllerInitialData){
        return data;

Feed the initial data to the graph

app.controller("appController", function ($scope, initialData) {
    $scope.collectedData = initialData;

By this approach you will not have to redraw the graph multiple times. And resoling the data is besst approach as we get the data before template loads.


Like @Chann said, add scope.$apply after your scope.collectedData.push line.

Or, wrap said line in scope.$apply, like so:

scope.$apply(function () {
  scope.collectedData.push({key:data.tenantIdentifier,y:data.dataPointValues[0].dataPointValues[ 0]});

Related Query

More Query from same tag