是否可以用ng-transclude
而不是整个模板元素替换元素?如何用ng-transclude替换元素
HTML:
<div my-transcluded-directive>
<div>{{someData}}</div>
</div>
指令:
return {
restrict:'A',
templateUrl:'templates/my-transcluded-directive.html',
transclude:true,
link:function(scope,element,attrs)
{
}
};
我-transcluded-directive.html:
<div>
<div ng-transclude></div>
<div>I will not be touched.</div>
</div>
我是什么寻找的方法是让<div>{{someData}}</div>
代替<div ng-transclude></div>
。目前发生的情况是,被拦截的HTML被放置在内,ng-transclude
div元素中。
这可能吗?
谢谢你,swehren。 – Francisc
对我来说,'element'找到'div [my-transcluded-directive]',而不是模板。 –
@LittleBigBot如果你想发布小提琴我会看看 – swehren