In Angular 1 my code looked like this:I have 2 dictionaries and functions
var rus = {"hello" : "привет",
"text":"текст",
"home":"дом"};
var eng = {"hello":"hello",
"text":"text",
"home":"home"};
$scope.selectedLang = rus;
translate();
function translate() {
$scope.hello = $scope.selectedLang["hello"];
$scope.text = $scope.selectedLang["text"];
$scope.home = $scope.selectedLang["home"];
}
$scope.switchLang = function(lang) {
if(lang == "rus") {
$scope.selectedLang = rus;
} else {
$scope.selectedLang = eng;
}
translate();
};
But now I need to make this in angular 2. How can I do this?
{{User}}
` ? – Sveta Antrapovich Jul 11 '16 at 12:05User
`. What should I do to translate this word? Use {{ }}? – Sveta Antrapovich Jul 11 '16 at 12:42User
`and then on button click you can pass it as `` so it will be passed as input to translate method. if your problem is solved then close this question by accepting any of the answers. – Bhushan Gadekar Jul 11 '16 at 13:09