0

I've got some html that looks like this

columns = [<span ng-repeat-start= "col in colsList">"{{col}}"</span><span ng-repeat-end></span>] 

Which is giving me nearly the correct output, something like this.

columns = ["a" "b" "c" "d"]

Is there anything within angular that will allow me to easily separate these items with commas? I tried doing this

columns = [<span ng-repeat-start= "col in colsList">"{{col}}, "</span><span ng-repeat-end></span>] 

Which ended up giving me output such as this.

columns = ["a", "b", "c", "d",]

Which is so close to what I want, but I cannot have the extra comma after the "d".

So, is there anything in angular like this, that will allow me to represent a typical list inside the view, separated by a delimeter, in this case a comma?

1 Answer 1

2
[<span ng-repeat="col in colsList">"{{ col + ($last ? '"' : '", ') }}</span>]
Sign up to request clarification or add additional context in comments.

10 Comments

It appears as though the end bracket of my list is being included as a part of the quotation (it is colored green, the color of strings in my editor), Is there a way to not include the final bracket as a part of the last string in the list? I've tried messing around with the variables next to "$last" without luck
Your editor is confused, but the code is correct. Try using &quot; instead of ", maybe that will make your editor happy.
I don't know why I said editor.. browser is what I meant. Same case though
Even in your example here, the final span tag is considered "quoted"
A browser doesn't color quotes in green. The code works fine here on Firefox, Safari and Chrome: plnkr.co/edit/lNCjNQzACsD45f4UkyBp?p=preview. What is the problem?
|

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.