11

I am writing a web app using AngularJS. The user submits up to 3 keywords to the server. I would like to show commas in between the keywords only if there are enough keywords.

For example:

if there are no keywords, then:

if there is 1 keyword, then: keyword

if there are 2 keywords, then: keyword, keyword

if there are 3 keywords, then: keyword, keyword, keyword

I have the following code:

    <tr>
       <td>Keywords: </td>
       <td>{{post.Keyword1}} <span ng-show = "{{post.Keyword2}}">,</span> {{post.Keyword2}} <span ng-show = "{{post.Keyword3}}">,</span> {{post.Keyword3}}</td>
    </tr>

Why does this not work?

OneMoreQuestion
  • 1,544
  • 2
  • 19
  • 43

1 Answers1

17

Change it to

<td>{{post.Keyword1}} <span ng-show = "post.Keyword2">,</span> {{post.Keyword2}} <span ng-show = "post.Keyword3">,</span> {{post.Keyword3}}</td>
Vineet
  • 4,279
  • 3
  • 19
  • 42