角转换正在努力改变我的HTML。 我为ngDropdown按钮指令,也有改变选择项目的数组。 更改语言后,我试图让与translate.use新的/当前的语言()。 东西不起作用。
这里的HTML
<div id="postBox" class="floatingSection" data-ng-controller="postButtonController2">
<button id="postButton" dropdown-menu="ddMenuOptions" dropdown-model="ddMenuSelected" class="btn-menu" ng-click="getCurrentLanguage()">{{ 'POST' | translate }}</button>
</div>
下面是该postButton控制器。 它应该从$翻译并使用该字符串来获得下拉选择数组新的/当前的语言,硬编码时ddSelections.withLangChoice $ scope.getCurrentLanguage选择正确的阵列,而不是在从$获取变量转换为语言的字符串。
这是一个有一个下拉按钮控制器。 注释描述工作不上几行的东西和事情。
residenceApp.controller('postButtonController2', ['$translate', '$scope', 'changePostDdFactory',
function ( $translate, $scope, ddSelections ){
//ddSelections is the result object from the function returned by changePostDdFactory
$scope.getCurrentLanguage = function( $translate ){
alert('here I am in postButtonController2'); //fires on post button clicks and on page load
alert('here I am in postButtonController2' + $translate.use()); //does not fire on post button clicks. fires on page load
$scope.langKey=$translate.use(); //gets langKey in $translate on page load only
$translate.refresh($scope.langKey);//should refresh the translation, but nothing
alert('from postButtonController2 - currentLanguage is' + ' ' + $translate.use() ); //does not fire on button click. fires on page load
//return 'es'; //hardcoded works on page load & sets ddSelections.withLangChoice to es array
return $translate.use(); //sets language for ddSelections on page load, no language changes
};
$scope.ddMenuOptions = ddSelections.withLangChoice($scope.getCurrentLanguage($translate)); //works on page load, no language change occurs
$scope.ddMenuSelected = {};
//working code to watch for change from user selection
}]);
我是新的,但,在控制器不应$翻译服务工作。 假设这是真的,什么也改变发生的变化来获得。 我最近增加了NG-点击到HTML的按钮,但它本身也没有任何影响。