0

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
1
  • 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? Commented Sep 25, 2015 at 10:35

2 Answers 2

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
Sign up to request clarification or add additional context in comments.

1 Comment

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>
0

You can simply show

<div>{{category}}</div>

No need to check

answered Sep 25, 2015 at 10:32

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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.