javascript - Change one single iteration on an ng-repeat -


i have ng-repeat iterates through names of countries in model. on country names want them abbreviated reduce length of string, example, want 'northern ireland' outputted 'n. ireland'.

json model

[   {     "id": 1,     "name": "italy",   },    {     "id": 2,     "name": "northern ireland",   },    {     "id": 3,     "name": "poland",   } ] 

i change name in model, i'd rather leave as want raw data complete. in specific instance want have abbreviated.

should use ng-repeat filter? if so, how?
if not, other suggestions?

html

<md-grid-tile ng-repeat="nation in nationdata">    <img src="img/{{nation.name}}.png">    <md-grid-tile-footer>     <h3>{{nation.name | uppercase}}</h3>   </md-grid-tile-footer>  </md-grid-tile> 

you create own filter abbreviate applied name. in filter switch on country name , return abbreviated format.

app.filter('abbreviate', function() {      return function(country) {          switch(country){             case "northern ireland":                 country = "n. ireland"                 break;         }          return country;      }  }); 

Comments