Angular-translate(Pascalprecht)$ translate服务没有返回承诺

时间:2017-09-27 19:27:27

标签: angularjs angular-translate

我使用angular-translate(Pascalprecht)插件来翻译我的Angular1.0.7 Web应用程序。

在某些时候我需要在我的控制器中使用$ translate服务(有时你需要它)。呼叫$scope.departurePhoto = $translate(photoName);不再翻译,因为在运行时,翻译服务$translate.uses(language).then(function() {仍在运行。

我已阅读官方文档https://angular-translate.github.io/docs/#/guide/03_using-translate-service,我们认为$ translate服务会返回承诺,例如:

$translate(photoName).then(function (departurePhoto) {
                    $scope.departurePhoto = departurePhoto;
                    console.log("destinationHelper.departurePhoto=" + $scope.departurePhoto);
                }, function (translationId) {
                    $scope.departurePhoto = translationId;
                    console.log("destinationHelper.departurePhoto con translationId=" + $scope.departurePhoto);
                });

Howerver,我在通话中遇到错误:TypeError: $translate(...).then is not a function

从一开始或从任何特定版本开始工作吗?我使用相当古老的角度转换1.1.0分钟。版本

注意:我尝试升级到最新的稳定角度翻译版本。它应该是所有版本都兼容,所以只是替换了lib文件,它没有用。我收到了下一个错误:

Uncaught TypeError: g.has is not a function     at Constructor.$get (angular-translate.min.js:6)

我知道这些是两个问题,所以如果可能的话,我想先解决我的问题而不先升级。

0 个答案:

没有答案
相关问题