私がやっていることの非常に煮詰めたバージョンがあり、問題を解決しています。
私はシンプルdirective
です。要素をクリックするたびに、別の要素が追加されます。ただし、正しくレンダリングするには、最初にコンパイルする必要があります。
私の研究は私をに導きました$compile
。しかし、すべての例は複雑な構造を使用しており、ここでの適用方法がよくわかりません。
フィドルはこちら: http://jsfiddle.net/paulocoelho/fBjbP/1/
そしてJSはここにあります:
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>");
});
}
};
});
Josh David Millerによるソリューション: http://jsfiddle.net/paulocoelho/fBjbP/2/