I have a value {{category}} which is to printed using angular js. Based on the value I have to change the contents of div.
if {{category}} = "aa" then <div>aa</div>
if {{category}} = "bb" then <div>bb</div>
how is this possible.
Dyrandz Famador
4,5256 gold badges28 silver badges40 bronze badges
asked Sep 25, 2015 at 10:28
Dhanya
5891 gold badge6 silver badges14 bronze badges
-
Why not something like <div>{{category}}</div> is this what you are looking for? Or the value of category is not what you actually want to show?It-Z– It-Z2015年09月25日 10:35:12 +00:00Commented Sep 25, 2015 at 10:35
2 Answers 2
Use ng-if:
<div ng-if="category === 'aa'">aa</div>
<div ng-if="category === 'bb'">bb</div>
Or:
<div>{{category}}</div>
answered Sep 25, 2015 at 10:30
CD..
74.4k25 gold badges160 silver badges170 bronze badges
Sign up to request clarification or add additional context in comments.
1 Comment
Dhanya
It worked for me. My implemented code is <span ng-if="category == 'clothes'"><img src="images/Clothes.jpg" id="img"/></span> <span ng-if="category == 'books and media'"><img src="images/books.jpg" id="img"/></span>
You can simply show
<div>{{category}}</div>
No need to check
answered Sep 25, 2015 at 10:32
Hardik Gondalia
3,7276 gold badges39 silver badges86 bronze badges
Comments
default