This probably works, but it confuses me: you are iterating over an array and then change that array.

var res = [];
angular.forEacht(langs.split(','), function(lang) {
  res.push({

  });

}