image-multiselectというanglejsディレクティブを作成しました。これは次のように使用できます。Angularjsディレクティブ:String to directiveとして渡されたhtmlがテンプレートにレンダリングされない
<image-multiselect items="landTransportTypes" image="illustrationURL" itemname="name" append="<div class='detail'>...some html here...</div>"></image-multiselect>
append属性には、文字列としてhtmlが割り当てられていることに注意してください。私は
function(){
var imageMultiselect = function(){
return {
scope : {
items: "=",
image: "@",
itemname: "@",
append: "@"
},
template : "<div style='background:#f2f2f2;padding:20px;margin:20px;border-radius:5px;min-height:100px;'>" +
"<div ng-repeat='item in items' class='card text-center'>" +
"<img class='card-img' src='{{item[image]}}' alt='Avatar'>" +
"<div class='detail'>" +
"<b>{{item[itemname]}}</b>" +
/*append used to customize template as per requirement*/
"{{append}}"+
"</div>" +
"</div>" +
"</div>"
}
}
angular.module("myApp").directive("imageMultiselect",imageMultiselect);
}());
問題を次のようにDDOにtemplate
属性を変更するために使用することを期待このHTML文字列:APPENDに渡されたHTML文字列は、全体ではなく、マークアップは、それがページ上にあるように表示されるHTMLとしてレンダリングされていませんか?
使用NG-バインドによって
ng-html-compile
ディレクティブを使用しました-html、else評価されていない –