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.

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

Comments

Your Answer

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.