S
S
Sergey2015-06-06 14:28:57
Angular
Sergey, 2015-06-06 14:28:57

How to retrieve the necessary data from the service?

In addition to my previous question .
How to get data back

[{
  "name": {
    
    "en": "name-english",
    "de" : "name-deutch"
  }, 
   "title": {
     "en": "english title",
     "de": "deutch title"
   } 
}]

from the service according to the required language?
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; // Здесь ведь надо что-то сделать с ними и с CurrentLanguage
     	return data
    }
]);

$scope.data = DataJson.query();
view controller
<div ng-repeat="vm in data">
    {{vm.name}}<hr>
      {{vm.title}}
  </div>

Plunker

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question