Check out this functional plunk that meets your requirements:
http://plnkr.co/edit/HcoyFyCSnrfmLu3lI7a6
The beauty of this setup is that each directive operates independently with its own scope object. You no longer even need a controller.
Also refer to:
Your updated directive definition:
app.directive('panelTrigger', function() {
return {
scope:{},
link: function($scope, element, attrs) {
$scope.toggle = function() {
$scope.visibility = !$scope.visibility;
};
// Default visibility is false
$scope.visibility = false;
$scope.$watch(attrs.visible, function( newValue, oldValue ) {
if ( newValue === oldValue ) {
return;
}
var elm = angular.element(element.children()[1]);
if (newValue) {
elm.attr('style', 'display: block;');
} else {
elm.attr('style', 'display: none;');
}
});
}
};
})
Additionally, make a slight adjustment to your HTML code:
<div data-panel-trigger data-visible="visibility">
<a ng-click="toggle()" href="#">Panel A</a>
<div class="panel span2">
<p>Panel Content</p>
</div>
</div>