Thank you for the quick response, Sander. I have updated my directive to
match your fiddle but I am having similar results... chart is not rendering
due to $scope.model.data values being undefined.
Since I last posted the fiddle the returned object has changed to the
following for both $resource calls:
{
"type": "count",
"data": [50]
}
When I reference $scope.getCount.data[0] and $scope.getCountGET.data[0] I
receive the following error in the console: *TypeError: Cannot read
property '0' of undefined*
I also see that the data property in $scope.model.data is undefined when I
console log ($scope.model) and inspect the returned object.
This is what makes me wonder if the directive is firing before the
$resource call returns and then fails to update once the model changes.
On Thursday, January 2, 2014 3:08:25 PM UTC-6, Paul McCaughtry wrote:
>
> Hi,
>
> I am having issues rending charts (directive) when the data to populate
> the chart is obtained from a service call using $resource (and $http). The
> chart is rendered from a directive in an html view template.
>
> I understand that $resource returns an empty object or array based on the
> call type and views will update once the data is returned from the service
> call. I'm assuming directives do not act the same way because the charts
> never render. It appears that the directive is passed an undefined value
> and fails to render but the view updates as expected.
>
> Is this something that can be remedied by processing promises prior to
> loading a controller from the route provide or is there another method? I
> have tried setting the data model (i.e., $scope.model.data) by calling the
> service then chaining $promise.then() callback without success. I'm new to
> promises and do not understand all applications to solve my issue (if this
> is the case).
>
> Any help is appreciated. I have a thread opened on
> StackOverflow<http://stackoverflow.com/questions/20692357/flotcharts-not-rendering-with-angularjs/>as
> well as a
> jsFiddle <http://jsfiddle.net/paulmc/H6Y5c/>. Note, the jsFiddle is good
> for showing my code but cannot reproduce the issue because I don't know how
> to make async calls. I attempted to return data from Github but this has
> been unsuccessful.
>
> I recently upgraded from v1.0.7 to v.1.2.5.
>
> Thank you,
>
> Paul
>
--
You received this message because you are subscribed to the Google Groups
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/groups/opt_out.