Angularjs 如何将转换添加到现有的角度属性指令?
我也经历过类似的问题,我想我还是不明白这是怎么回事 我想修改以下指令以允许转换:Angularjs 如何将转换添加到现有的角度属性指令?,angularjs,angularjs-directive,transclusion,Angularjs,Angularjs Directive,Transclusion,我也经历过类似的问题,我想我还是不明白这是怎么回事 我想修改以下指令以允许转换: app.directive('ccWidgetHeader', function() { var directive = { link: link, scope: { 'title': '@', 'subtitle': '@', 'rightText': '@', 'allowCo
app.directive('ccWidgetHeader', function() {
var directive = {
link: link,
scope: {
'title': '@',
'subtitle': '@',
'rightText': '@',
'allowCollapse': '@'
},
templateUrl: '/app/layout/widgetheader.html',
restrict: 'A',
};
return directive;
function link(scope, element, attrs, ctrl, trans) {
attrs.$set('class', 'widget-head');
}
});
该模板与此类似(还有更多,但为了简洁起见,我删除了):
{{title}
我使用的HTML是:
<div data-cc-widget-header title="Last 20 Jobs"
allow-collapse="true">
<span>I want the content here included in my template!</span>
</div>
我希望这里的内容包括在我的模板中!
我想我可以在指令中添加“transclude:true”,然后修改模板,如下所示:
<div class="page-title pull-left">{{title}}<<ng-transclude></ng-transclude></div>
{{title}}您使用的是什么版本的Angular?代码如下:
<div class="page-title pull-left">{{title}}<<ng-transclude></ng-transclude></div>
<div data-cc-widget-header="" title="Last 20 Jobs" allow-collapse="true" class="widget-head"><div class="page-title pull-left ng-binding">Last 20 Jobs
<span>I want the content here included in my template! </span>
</div>