I haven't found, despite the many similar questions, how to hide a DOM element with ng-show
in a parent scope from a child scope.
I've got two nested controllers.
In the parent one (attached to ), I'm using the youtube embed directive to be able to read the video continuously despite changing views in ng-view
.
<html ng-app="app" ng-controller="ParentCtrl">
<body>
<youtube-video id="player" ... ng-show="selectedVideo.showVideo"></youtube-video>
<div ng-view></div>
</body>
</html>
When I first reach a route defined in ngRoute, the parent controller methods are called and in both controller I can decide to show or hide the video with
$scope.selectedVideo.showVideo = true;
And the video is displayed or hidden as I wish.
However, when I use the back button, the parent controller methods are not called, but I call nevertheless
$scope.selectedVideo.showVideo = false;
But the video still shows...
And at that point, when I refresh the page entirely (and manually...) the video finally gets hidden.
I'm not sure to understand why this is the case...
I basically would like to have some ngRoute views that display the video, and other which don't. That is, I would like the ng-show from the parent controller to be set to true/false from the child controller...
Any idea how can I achieve that?
I tried to use $scope.$parent
with both an object as above and a primitive, but that didn't change a thing.
It's as the actual value used for ng-show is updated but ng-show being out of the ngView isn't refreshed...