angular-translate: filter ignores namespace

大兔子大兔子 提交于 2019-12-12 03:59:22

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!