Angularjs How To Recompile A Dynamically Loaded Directive
I've been messing around with this all morning to isolate my problem. I am dynamically loading a directive by name when my page loads. Now I want to be able to change that dynamica
Solution 1:
Just listen to change and update it. http://plnkr.co/edit/NuSOA64QJ5Qro3L72zzZ?p=preview
link: function($scope, $element, $attr) {
console.log('loaddirective link');
var value = $scope.loaddirective;
function update (value) {
$element.html("<div " + value + " directivedata='directivedata'></div>");
$compile($element.contents())($scope);
}
if (value) {
update (value);
}
$scope.$watch('loaddirective', update);
},
Post a Comment for "Angularjs How To Recompile A Dynamically Loaded Directive"