3

Pretty new to angular so maybe I'm missing something obvious. I have a model with collection of objects with own properties; and I'm trying to create a csv value out of Text property of that object. I've tried few things and got it to work with both ng-repeat and by calling a function. However what I thought was the most straight forward way of doing this is not quite working.

{{item.Keywords.map(function (kw) { return kw.Text; }).join(', ')}}

In this example join works just fine (i see object separated by commas), however when combined with map it's unable to interpret it and just prints out it as is. Is there a trick to using map that I'm missing?

1
  • 2
    I think you're taking angular expressions a bit too far. You don't want to include functions in your templates. Commented Dec 13, 2013 at 21:39

1 Answer 1

5

Angular expressions can't do everything you can do in javascript. Check out the angular docs for expressions for more detail on what they can and can't do. I don't think you can declare a function in an angular expression so that is probably why your particular example is not working.

In general you should try to keep the logic in a view to a minimum. You can always just move the logic from your expression into a function on the controller.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.