Tengo una versión muy resumida de lo que estoy haciendo que resuelve el problema.
Tengo un simple directive. Cada vez que hace clic en un elemento, agrega otro. Sin embargo, debe compilarse primero para representarlo correctamente.
Mi investigación me llevó a $compile. Pero todos los ejemplos usan una estructura complicada que realmente no sé cómo aplicar aquí.
Los violines están aquí: http://jsfiddle.net/paulocoelho/fBjbP/1/
Y el JS está aquí:
var module = angular.module('testApp', [])
.directive('test', function () {
return {
restrict: 'E',
template: '<p>{{text}}</p>',
scope: {
text: '@text'
},
link:function(scope,element){
$( element ).click(function(){
// TODO: This does not do what it's supposed to :(
$(this).parent().append("<test text='n'></test>");
});
}
};
});
Solución de Josh David Miller: http://jsfiddle.net/paulocoelho/fBjbP/2/