我有一个类似的简单指令:
指令js:
.directive('pageHeader', function() {
return {
restrict: 'E',
scope: {
title: '=',
subtitle : '='
},
templateUrl: 'pages/templates/pageHeader.html'
};
})
指令html:
<div class="page-header">
<span class="header-view-title" ng-bind="title"></span>
<span class="header-view-subtitle" ng-bind="subtitle"></span>
</div>
我是这样使用这个指令的:
<page-header title="'The blue elephant'" subtitle="'is walking to the street'"></page-header>
有一种方法可以将过滤器传递到"title"one_answers"subtitle",然后使用该过滤器。我试过这样做,但失败了:
<page-header title="The blue elephant | myfilter" subtitle="is walking to the street | myfilter"></page-header>
有人已经需要做这样的事情了吗?
你的这个:
title="'The blue elephant' | myfilter"
^-- note quotes --^