While creating a directive inside another parent directive and then appending the compiled element to the parent's node using $compile(template)(scope), I noticed that although the directive is correctly created, the link function is not being triggered.
var displayProductsOnPage = function(template, items) {
for (var i = 0 ; i < items.length ; i++) {
var item = items[i];
var itemScope = $scope.$new(true);
itemScope.item = item;
var itemDirective = $compile(template);
var itemElement = itemDirective(itemScope);
element.append(itemElement);
}
}
Is there a way to explicitly call the link function after compiling the template?