Demo fiddle
Related to a comment at http://www.bennadel.com/blog/2712-refactoring-bnrepeatswitch-to-use-a-multi-priority-directive-in-angularjs.htm.
by ExpertSystem
HTML
<script src="http://code.angularjs.org/1.3.7/angular.min.js"></script>
<div dir1="" dir2="">All the fun is in the console.</div>
<!-- -=-=-=-=- -=[IGNORE BELOW THIS LINE]=- -=-=-=-=- -->
<!-- Page Footer -->
<small class="footer" ng-controller="footerCtrl">
<b>Angular v{{version.full}}</b> ({{version.codeName}})
<span class="right">
©
<a ng-href="{{author.url}}" target="_blank">{{author.name}}</a>
</span>
</small>
CSS
/* -=-=-=-=- -=[IGNORE BELOW THIS LINE]=- -=-=-=-=- */
/* Page Footer */
body { padding-bottom: 22px; }
.footer { background-color: White; border-top: 1px solid rgba(100, 100, 100, 0.33); bottom: 0; display: block; font-size: 0.75em; height: 20px; left: 0; margin: 0 5px; overflow: auto; padding: 5px; position: fixed; right: 0; }
.right { float: right; }
JavaScript
var app = angular.module('myApp', []);
app.directive('dir1', function () {
return {
priority: 1000,
controller: function () { console.log('Dir 1 - controller'); },
compile: function () {
console.log('Dir 1 - compile');
return {
pre: function () { console.log('Dir 1 - Pre-linking'); },
post: function () { console.log('Dir 1 - Post-linking'); }
};
}
};
});
app.directive('dir2', function () {
return {
priority: 1001,
controller: function () { console.log('Dir 2 - controller'); },
compile: function () {
console.log('Dir 2 - compile');
return {
pre: function () { console.log('Dir 2 - Pre-linking'); },
post: function () { console.log('Dir 2 - Post-linking'); }
};
}
};
});
/* -=-=-=-=- -=[IGNORE BELOW THIS LINE]=- -=-=-=-=- */
/* Page Footer */
app.controller('footerCtrl', function ($scope) {
$scope.version = angular.version;
$scope.author = {
name: 'ExpertSystem',
url: '//stackoverflow.com/users/2341938/expertsystem'
};
});