问题
I'm using angular-translate. And it seems that filter-based translation does not use translate-namespace defined with attribute-level directive above. AFAIK it's because filter cannot process scope chain. Is there a way to connect filter-based translation to namespaces?
<div translate-namespace="form">
<translate>create-new</translate> <!-- this works respecting namespace -->
</div>
<div translate-namespace="list">
{{"create-new"| translate}} <!-- this doesn't use namespace at all -->
</div>
回答1:
[OLD] Actually it's about angular fundamental things.
Filters are executed outside the scope context. So there is no ability to respect namepspaces that are declared through directive and are saved in the scopes chain.
[UPD] Actually translate-namespace directive stores (concatenated - in case of namespaces are nested) namespace value in the $scope. So it's possible to use property translateNamespace:
<div translate-namespace="sectionA">
....
{{translateNamespace + '.innerKey' | translate}}
来源:https://stackoverflow.com/questions/32764496/angular-translate-filter-ignores-namespace