Sam Sam - 1 year ago 44
AngularJS Question

How can I change a value inside of ng-repeat after the repeat complete?

I have a JSON which provides me a user's working experiences info. But country and city's are provided in a code format (TR,DE etc.)
I am using ng-repeat to pass them into html like this

<div ng-repeat="e in experiences">
<span ng-init="changeCodeToFullName(e.Country)">{{vm.CountryFullName[$index]}}</span>

I am using ng-init to convert Country Code to full name. changeCodeToFullName is an angular service written by me, Is this a correct method? If it is, I can't access the dom to change CountryFullName value. I tried to access them in JS file like
but it didn't worked. I need to use e.Country variable after, therefore I can't change the original .e.Country value.

How can I access a variable inside of ng-repeat after ng-repeat completed?


How about using a custom filter:

<div ng-repeat="e in experiences">
    <span>{{e.Country | changeCodeToFullName}}</span>

angular.module('App').filter('changeCodeToFullName', function(YourService) {
    return function(country) {
        return YourService.getFullCountryName(country)

Here's an example: