I thought of 2 ways. This solution I find much less hacky, but is also less dynamic:
angular.module('example').directive('dir1', function () {
return {
restrict: 'A',
scope: true,
controller: 'ExampleCtrl',
link: function(scope) {
$scope.myDir="dir1";
}
};});
angular.module('example').directive('dir2', function () {
return {
restrict: 'A',
scope: true,
controller: 'ExampleCtrl'
link: function(scope) {
$scope.myDir="dir2";
}
};});
In this way you are baking the parent directive into the scope, which is available to the controller.
This solution is more hacky, but also more dynamic. Using this question, we can get our containing element:
function innerItem($scope, $element){
var jQueryInnerItem = $($element);
}
from there, we can test that element for attributes and properties that would be specific to one directive over another (such as directive name). I still think this is very hacky and you have an underlying issue (perhaps a bit of XY problem here), but this should work.