Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Child scope access problems #61

Open
zhukov opened this issue Sep 23, 2014 · 0 comments
Open

Child scope access problems #61

zhukov opened this issue Sep 23, 2014 · 0 comments

Comments

@zhukov
Copy link

zhukov commented Sep 23, 2014

My template

<div class="audio_player_wrap">
    <audio ng-if="audio.url" media-player="mediaPlayer" autoplay="autoplay">
      <source ng-src="{{::audio.url}}" type="audio/ogg" />
    </audio>
</div>

Due to ng-if directive creates new child scope, I can't access $scope.mediaPlayer in parent directive. It's the same problem as when using ng-model with expression without dot; caused by prototype inheritance in AngularJS.
I used this workaround:

--- a/app/vendor/angular-media-player/angular-media-player.js
+++ b/app/vendor/angular-media-player/angular-media-player.js
@@ -430,7 +430,9 @@ angular.module('mediaPlayer', ['mediaPlayer.helpers'])
         } else {
           playlist = scope[playlistName];
         }
-        if (mediaName !== undefined) { scope[mediaName] = player; }
+        if (mediaName !== undefined) {
+          scope.$eval(mediaName + ' = player', {player: player});
+        }

with attribute media-player="mediaPlayer.player" and defined $scope.mediaPlayer = {} in parent directive.
The same probably applies to playlist attribute.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant