Angular ng-show, if the line is not empty, does not work

I am writing a web application using AngularJS. The user sends up to 3 keywords to the server. I would like to show commas between 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 is this not working?

+7
angularjs angularjs-ng-repeat angularjs-ng-show ng-show angular-ng-if
source share
1 answer

Change it to

 <td>{{post.Keyword1}} <span ng-show = "post.Keyword2">,</span> {{post.Keyword2}} <span ng-show = "post.Keyword3">,</span> {{post.Keyword3}}</td> 
+13
source share

All Articles