You can take advantage of the fact that linking is done in two phases. You could first register all children in "pre-link phase" and then, in "post-link phase", you'd have access to the required information.
.directive('parent', function () {
return {
controller: function () {
this.childCount = {
pre: 0,
post: 0
};
},
link: function () {}
};
})
.directive('child', function () {
return {
require: '^parent',
compile: function () {
return {
pre: function ($scope, $element, $attrs, parentCtrl) {
++parentCtrl.childCount.pre;
},
post: function ($scope, $element, $attrs, parentCtrl) {
++parentCtrl.childCount.post;
if (parentCtrl.childCount.post === parentCtrl.childCount.pre) {
// ... (this runs only on the last linked child)
}
}
};
}
};
})
This way you have access to that information during last child's linking.
Of course, if you don't need the info that soon, you could just register all child controllers in the parent controller and then run a method of the last registered child controller from the parent post-link function.