【发布时间】:2016-01-12 19:43:07
【问题描述】:
我正在使用带有自定义功能的 ng-show。该函数在控制器内部调用“$translate.use”方法。
很有趣,这适用于主页,但不适用于所有其他控制器,尽管它们都使用相同的代码和平。
控制台告诉我 $translate 未定义。
这是我的索引页面代码:
app.controller('LangCtrl', function ($scope, $translate) {
$scope.isenglish = function () {
if ($translate.use() == 'en_US') {
return true;
}
return false;
}........
对于另一个控制器:
app.controller('selectFormController', ['$scope', '$http', 'storage', '$rootScope', function ($scope, $http, storage, $rootScope, $translate) {
........
$scope.isenglish = function () {
if ($translate.use() == 'en_US') {
return true;
}
return false;
}
我真的很困惑 - 有人可以帮助我吗?
非常感谢!!! 史蒂芬
【问题讨论】:
-
我猜你打错了.. app.controller('selectFormController', ['$scope', '$http', 'storage', '$rootScope', function ($scope, $ http, storage, $rootScope, $translate) { 应该是 app.controller('selectFormController', ['$scope', '$http', 'storage', '$rootScope','$translate', function ($scope , $http, 存储, $rootScope, $translate) {
标签: angularjs dependency-injection angular-translate