2015-12-03 28 views
1

我想翻譯我的麪包屑元素是這樣的:翻譯angularjs麪包屑在stateprovider

網址:moduls/1 /問題

痕跡:Moduls - > MODUL 1 - >問題

問題是「模塊1」部分。我的翻譯,這是

"MODUL_TAG": "Modul {{short}}" 

breadcrumbtemplate:

<ol class="navbar-nav list-unstyled"> 
    <li ng-repeat="step in steps" ng-class="{active: $last}" ng-switch="$last || !!step.abstract"> 
     <a ng-switch-when="false" href="{{step.ncyBreadcrumbLink}}" title="{{ step.ncyBreadcrumbLabel }}">{{step.ncyBreadcrumbLabel | translate:translationData }}</a> 
     <span ng-switch-when="true">{{step.ncyBreadcrumbLabel | translate:translationData }}</span> 
    </li> 
</ol> 

國家:

.state('modul.show', { 
    url: "/{short}", 
    templateUrl: "partials/modul/show.html", 
    controller: "ModulShowCtrl", 
    ncyBreadcrumb: { 
     label: "MODUL_TAG" 
    } 
}) 

的問題是,我不知道我必須把翻譯的數據。

我試過用ModulShowCtrl但沒有成功。

$scope.$parent.translationData = { 
    short: $stateParams.modulId 
}; 

回答

1

你應該在你的狀態定義你的翻譯痕跡,就像這樣:

.state('modul.show', { 
    url: "/{short}", 
    templateUrl: "partials/modul/show.html", 
    controller: "ModulShowCtrl", 
    ncyBreadcrumb: { 
     label: '{{ "MODUL_TAG" | translate }}' 
    } 
})