mardi 21 février 2017

What is best way to connect data from different services and use them with ng-model

I'm new to angular and to design some complicated things...

I have two services: phrasesService and translationsService, they stores two objects:

phrases = [ {text: "phrase1"}, {text: "phrase2"}, {text: "phrase3"} ]
    
translations = [ { language: "russian", phrases: ["phrase1", "phrase2", "phrase3"] }, { language: "hindi", phrases: ["phrase1", "phrase2, "phrase3"] }]

And I have methods to get translations:

getTranslationsInLang(lang) , that returns array of phrases in lang and getPhraseTranslation(lang, numPhrase) , that returns translation of one phrase

Now I want to display phrases and their translations in inputs (for editing):

<input class="form-control phrase-text" type="text" ng-model="phrase.text">
<input class="form-control translation-text" type="text" ng-model="????.translation">
  1. What is the best way to realize this, for store all data and display it for editing?
  2. And what should I use in ng-model for translation input?

Aucun commentaire:

Enregistrer un commentaire