您可以使用ng-attr,这将是更方便的解决方案. ng-attr-data-title将评估插值{{}}&使用值创建data-title属性.
而不是使用data-title =“{{‘我的字符串’| myfilter}}”使用ng-attr-data-title =“{{‘我的字符串’| myfilter}}”
标记
...
更新
因为你得到的价值就像{{‘我的字符串’| myfilter}},{{‘我的字符串2’| myfilter}}使用插值然后你可以使用$parse或$interpolate服务来评估它们.
.directive('sectionBuilder', function($interpolate){
return {
priority:100,
restrict: 'C',
link: function(scope, element, attrs){
var data = [];
$('.carousel-inner > .item', '#carousel').each(function(i, el){
data.push({k: i, v: $interpolate($(el).attr('data-title'))})
});
}
}
})