S
S
Sergey2015-06-06 01:19:49
Angular
Sergey, 2015-06-06 01:19:49

How to display $scope correctly?

There is $scope

$scope.data = {
      "name": {       
        en: "All",
        de: "Alles"      
            }
           };

Have CurrentLanguage
Need $scope.data output dependent on CurrentLanguage
<div ng-repeat="vm in data">
    {{vm.<Как сюда правильно подставить CurrentLanguage?>}}
  </div>

Example here
Updated the question
If you make translation a service, then how can you display only the existing language there?
I'm trying here
app.factory('DataJson', ['$resource','$translate',	function($resource, $translate) {
     var article = $resource('translate.json');
     
     var CurrentLanguage = $translate.use() || $translate.storage().get($translate.storageKey()) || $translate.preferredLanguage();
     	
     	var data = article;
     	return data
     	 	
  }
]);

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey, 2015-06-06
@TsarS

it is more correct to remove it from the template and resolve it at the service level, or at least in the controller. Well, so...
{{vm[CurrentLanguage]}}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question