3

I have method for getting data from server. And I use it in foreach, and after it need bind him to $scope variable. Like this:

var qualityMix = [];
var engagementMix = [];
angular.forEach(versions, function (versions) {
    qualityMix.push(qualityScoreByTimeWithAppVerPromise(versions.version));
    engagementMix.push(engagementByTimeWithAppVerPromise(versions.version));
});

$scope.qualityScoreByTimeMix = function () {
    return $timeout(function () {
        return $q.all(qualityMix).then(function (data) {
            return {series: data};
        });
    });
};

$scope.engagementTimeMix = function () {
    return $q.all(engagementMix).then(function (data) {
        return {series: data};
    });
};

qualityScoreByTimeWithAppVerPromise and engagementByTimeWithAppVerPromise it is functions for getting data from server. Then $scope.engagementTimeMix and $scope.qualityScoreByTimeMix need return functions with promise (is okay).

This code working but not always, some times I catch exceptions $scope.xxx is not a function.

I don't know how to fix it. Help me please. Thanks a lot!

UPD It is code for build charts.

<div class="section">
    <highchart id="mix_quality_score_by_time" type="area" data="qualityScoreByTimeMix"
               chart-style="qualityScoreMixChartStyle"></highchart>
</div>

And my directive I invoke in other page, like this:

<compare-versions id="compare_versions_panel" start-day="timeFilter.startDay()"></compare-versions>

$scope.xxx is not a function I mean what I catch message in chrome console what $scope.engagementTimeMix and $scope.qualityScoreByTimeMix it not a function

3
  • Could we see your controller and where you are actually calling these methods? Commented Feb 4, 2016 at 13:10
  • Exactly what is $scope.xxx? I don't see anything being called here just setting up for things being called. I don't see where you call $scope.qualtyScoreByTimeMix (no need for $timeout there) or $scope.engagementTimeMix Commented Feb 4, 2016 at 13:11
  • I updated my question Commented Feb 4, 2016 at 13:19

1 Answer 1

1

You can use ng-if and draw graph when you already have value
example:

<div class="section" ng-if="qualityScoreByTimeMix">
    <highchart id="mix_quality_score_by_time" type="area" data="qualityScoreByTimeMix" chart-style="qualityScoreMixChartStyle"></highchart>
</div>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.