$コンパイルが私の指示の中で正しく動作するようにはできません。私はng-bindディレクティブの中にhtmlを要素に挿入しようとしています。セレクタサービスからng-bindに変数を渡しています。
私は自分のhtmlを表示するとバインドが動作しません。代わりに、私は空の要素を取得します。 HTMLは次のようになりますコンパイルした後:
<div class = "song_info ng-binding ng-scope" data-ng-bind = "year"></div>
をこれは私が使用していますディレクティブです:
.directive("sortableQueue", ["$compile", "selector", function($compile, selector){
return{
scope : {},
link : function(scope, element){
element.sortable({
stop : function(event, ui){
//get helper html
var song_element = $(ui.item);
//logs correct value
console.log(selector.getValue());
var html = "<div class = 'song_info' data-ng-bind = '" + selector.getValue() + "'></div>";
var content = $compile(html)(scope);
song_element.html(content);
}
});
}
};
}])
誰かが私がここで作っていますどのような間違いを知っていますか?どんな助けもありがとうございます。
ノー変数年はありません。年はサービスセレクタに格納される変数の値です。私はそのサービスから変数をhtmlにバインドしようとしています。この指令には他の範囲は必要ありません。 – Palo
■私の答えを見てください) – Vitalii