私のコンポーネント(角2)にいくつかのhtmlを注入したいのですが、私は注入されたhtmlにメソッドを持っているため、angularjsで$ compileを使用してhtmlをDOMに注入していました。角度2を使用してコンポーネントにhtmlを挿入する方法
addTextField(){
var newTextBoxDiv = $(document.createElement('div'))
.attr("id", 'TextBoxDiv' + this.counter);
newTextBoxDiv.after().html('<label>Textbox #'+ this.counter + ' : </label>' +
'<input type="text" name="textbox' + this.counter +
'" id="textbox' + this.counter + '" value="" >'+'<span
(click)="removeTextField(this.counter)" class="glyphicon glyphicon-remove pull-
right" style="z-index:33;cursor: pointer"> </span>');
newTextBoxDiv.appendTo("#TextBoxesGroup");
}
removeTextField機能:
removeTextField(currentTextField){
alert(currentTextField);
}
私はそれは私がそれで削除スパンを(クリック)を意味しているdyanamicallyテキストフィールドを追加しよう= "removeTextField(this.counter doesntの相続人のコードを実行) "コードに記載されているように、私はこのスパンをクリックしようとしたときの問題は何も実行しないfunc助けてください
jqueryではなく角度で必要ですか? –
yess angular 2 ...何が欲しいのですか?関数はすべてを実行します –
'ngIf'と' [innerHTML] 'を探しています –