I have custom directives like this:
<fold fold-name="Musique et sons">
<sound-button height=60 song-name="Why Make..."></sound-button>
</fold>
fold directive has such template:
<button class="fold" ng-click="showMe = !showMe">{{foldName}} ({{nb}})</button>
<div class="fold" ng-transclude ng-show="showMe"></div>
In the sound-button controller, I have to do this:
$scope.$parent.$$prevSibling.$emit('foldstop')
If I want the controller to receive the event:
$scope.$on 'foldplay', (sender, evt) ->
What's happening: creates 3 scopes :
<fold> Scope
<ng-transclude scope> which has no model, thus no controller.
<sound-button scope>
In sound-button directive, $scope.$emit would hit the ng-transclude scope which is a sibling of the scope I want to hit.
So I'm using $scope.$parent.$prevSibling to hit the right controller. It works, but is there a better way ?
Thanks !