Stealth Rabbi Stealth Rabbi - 2 months ago 5x
AngularJS Question

optionall adding text at the end of an angular expression

I have an expression that's pull data from a controller, the number of pages of a book.

If the data exists, I want to print "X pages", where X is the value. Otherwose, I want the HTML paragraph to be blank.

But, I can't get the syntax correct. Below, it always prints out ' pages', even if blank. How do I set up my expression?

<p>{{ + ' pages' || "" }}</p>

I tried doing ternary operator in the expression, but didn't have lukc

<p>{{( > 0)?{{ + ' pages' :"" }}</p>



<p ng-if="">{{ }} pages</p>