When I press a button, a modal shows up. In that modal i have a
<template-placeholder></template-placeholder>
When the button is clicked, I do a if-check to make sure it's the correct button. If it is - then add another directive instead of the placeholder.
But I'm unable to get it to work.
Here is my directive:
.directive('modalDirective', function(){
return {
restrict: 'E',
scope: {
ctrl: '=',
modalId: '@',
},
template: ['<div id="{{modalId}}" class="modal fade" role="dialog">',
'<div class="modal-dialog">',
'<div class="modal-content">',
'<div class="modal-header">',
'<h4 class="modal-title">Modal Header</h4>',
'</div>',
'<div class="modal-body">',
'<p> {{ ctrl.text }} </p>',
'</div>',
'<div class="modal-footer">',
'<template-placeholder></template-placeholder>',
'<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>',
'</div>',
'</div>',
'</div>',
'</div>'].join(''),
link: function(scope, element, attrs) {
scope.$watch('modalId', function(val){
if(val == 'protocolModal'){
element.find('template-placeholder').replaceWith('<test-directive></test-directive>');
}
});
}
}
})
.directive('testDirective', function(){
return {
restrict: 'E',
template: '<div>this is our other directive speaking.</div>'
}
});
<template-placeholder>a directive or just a dummy element?