Closed labago closed 8 years ago
You have to broadcast player to rootscope. Then create a listener and convert it to local $scope.player
the root of the problem is that ng-if
creates a new scope. $scope.player
, when used in your controller, is being referenced from within the parent's scope, so it's undefined
.
depending on your needs, an ng-show
might work, since it doesn't create a new scope.
Whenever I try to do something like
$scope.player.setVolume($scope.playerSettings.volume);
I get an undefined error, meaning "player" is not defined. I do have the attribute on the directive set to a name like this:
<youtube-video ng-if="playerSettings.ready" video-id="currentVideo" player-vars="playerSettings" player="thePlayer"></youtube-video>
And doing something like this:
$scope.thePlayer.setVolume($scope.playerSettings.volume);
Gets the same undefined error. I am relatively new to angular but according to what I have read, the first example in this post should have worked right? What am I doing wrong?