Kumar Vaibhav
Kumar Vaibhav

Reputation: 2652

Value of variable not reflecting ng-view

I have a div that shows a highchart based on ng-view. Something like this -

<div ng-show="series" ng-controller="someController"
    <highchart config="someConfig" class="span9"></highchart>
</div>

series is a variable in $scope. When the page loads for the first time, series is null/undefined (falsy) but on click of a button, data is fetched and put in series variable (truthy). This change of state of series variable is not automatically picked by ng-view and my chart is not shown. I have tried things like calling a function in ng-view that returns $scope.series but it's not working. Please not that highchart is working fine since if I move it out of the above div, the chart shows up fine.

What could I be doing wrong? Is there a way that ng-view automatically gets notified of changes in $scope.series and it shows the div?

Thanking in anticipation.

Upvotes: 0

Views: 56

Answers (1)

Artem Petrosian
Artem Petrosian

Reputation: 2954

Assuming you are using ng-view, you probably declare controller in your $route service, so you don't need to use ng-controller directive within your view again:

<div ng-show="series">
    ...
</div>

This will cause the controller to be attached and executed twice and might be the root of your problem.

Also, it might be just a question typo, but you forgot > in your example html tag

Upvotes: 1

Related Questions