Angular - show key match with value

219 views Asked by At

In my page I can select a type. The type has following structure:

vm.types = {
    prospect: 'Prospekt',
    article: 'Artikel',
    photo: 'Photo',
    literature: 'Literatur'
}

In the template there is the select field which writes inside the current document the key of the type.

<select data-ng-model="file.docType" data-ng-options="key as value for (key , value) in vm.types">
    <option value="">Bitte auswählen</option>
</select>

So when the data comes from the database it has just the key saved as the docType of the file. When showing the data from the database I want to match the saved key with the values from the type variable. How can I do this?

<div>{{document.docType}}</div>
1

There are 1 answers

1
sanyooh On BEST ANSWER

Found a solution:

<div>{{vm.types[document.docType]}}</div>