I'm developing the i18n part of my Angular web app, and I'd like to use angular-translate in my config phase.
I defined some data that I'd like to translate:
.state('app.tracking', {
url: '/:IdentityIdentifier',
params:{
IdentityIdentifier: {squash: false, value: null}
},
templateUrl: 'views/pages/tracking.html',
data : { title: $filter('translate')('tracking.tracking.TITLE') },
resolve: load([], function(){ return loadGoogleMaps(); })
})
Here's my config declaration:
.config(
[ '$stateProvider', '$urlRouterProvider', '$locationProvider', 'MODULE_CONFIG', '$httpProvider', '$filter',
function ($stateProvider, $urlRouterProvider, $locationProvider, MODULE_CONFIG, $httpProvider, $filter) {
The error I get is classic: Error: [$injector:unpr] Unknown provider: $filter
I'm aware I can't use services in config phase, only providers, but is there a solution to my problem?
EDIT: My problem has been solved by assigning the key 'tracking.tracking.TITLE' to my data.title variable, then translating it using translate directive in my markup.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…