I'm creating a directive within another parent directive and then appending the directive's compiled element to the parent directive's node. $compile(template)(scope) correctly creates the directive, but the link function is not being called.
var addProductsToPage = function(template, products) {
for (var i = 0 ; i < products.length ; i++) {
var product = products[i];
var productScope = $scope.$new(true);
productScope.product = product
var productDirective = $compile(template);
var productElement = productDirective(productScope);
element.append(productElement);
}
}
How do I call the link function after I compile the template?