I am creating a web platform with angularjs and nodejs, I have a problem with the function of changing the language.
Routing:
$routeProvider
.when('/:lang?/index', {
templateUrl: 'modules/Home/HomeView.html',
controller: 'HomeCtrl'
});
Example url: link
View part of language change:
<ng-repeat ng-repeat="lang in availableLangs track by $index">
<li><a href="" ng-class="{'active': lang === currentLanguage}" ng-click="translate(lang)"> {{lang}}</a></li>
<li ng-if=" $index < availableLangs.length - 1">|</li>
</ng-repeat>
Controller, translate function
$scope.translate = function (langKey) {
if ($routeParams.lang) {
$route.updateParams({ lang: langKey });
}
$translate.use(langKey);
$scope.showLangSelector = false;
};
This is working for me, but I reload again the controller and the view, I want to know if there is an option to just change the url in the parameter: lang but without having to reload.
Thanks