Nix Nix - 9 months ago 55
AngularJS Question

Comma Separated <p> angular

I have a pretty basic scenario (somewhat new to angular). I am trying to convert JSON:

{'name': 'Nick'},
{'name': 'David'},
{'name': 'John'},



But I can not figure out how to generate a single "p." How do you call ng-repeat inside of the

<p ng-repeat="item in menuItems">{{}}</p>


One thing that would be helpful is creating a "map" filter, like so:

myModule.filter('map', function() {
  return function(input, propName) {
    return {
      return item[propName];

That's the simple case of mapping to a named property, you could make it more fancy and understand dot notation, etc. Now with this, in your view you can do:

  {{(menuItems | map:'name').join(',')}}

Because the map filter returns an Array, which has a built-in join method already in Javascript.