JSFiddle - React, Tailwind, and code Playground
HTML
<div ng-app="main" ng-controller="MyController">
<my-directive></my-directive>
<my-second-directive></my-second-directive>
</div>
JavaScript
var app = angular.module('main', []);
app.controller('MyController', ['$scope', function($scope){
var random = Math.random()*10000;
console.log('init random: ' + random);
$scope.test = function(controllerName){
console.log(controllerName + " " + random);
}
}]);
app.directive('myDirective', function(){
return{
require: "^MyController",
link: function(scope, els, attrs, req){
scope.test('myDirective');
}
}
});
app.directive('mySecondDirective', function(){
return{
require: "^MyController",
link: function(scope, els, attrs, req){
scope.test('mySecondDirective');
}
}
});