I need to write one 2 language website, one in English and another one in Danish. The data to be shown will be stored in json format, separately like name.en and name.de. There will be two buttons, one for for English and one for Danish.
But i don't want the coding like
<p ng-show="english">{{name.en}}</p>
<p ng-show="danish">{{name.de}}</p>
and also i don't to code want like
<div ng-switch on="isExists(item)">
<span ng-switch-when="true">{{name.en}}</span>
<span ng-switch-default>{{name.en}}</span>
<span ng-switch-when="false">{{name.de}}</span>
</div>
Where i am repeating the same code with English and Danish separately. I want to show it with a single line. Can anyone help me?
Try this simple example
Html
<button class="btn btn-info" ng-click="setLanguage('en')">English</button>
<button class="btn btn-info" ng-click="setLanguage('de')">Danish</button>
<p>{{name[language]}}</p>
Javascript
//inside controller
$scope.language='en'; //initial default value
$scope.setLanguage = function(language) {
$scope.language = language;
}