Dhanya
Dhanya

Reputation: 569

If condition using angular js

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.

Upvotes: 0

Views: 81

Answers (2)

Hardik Gondalia
Hardik Gondalia

Reputation: 3717

You can simply show

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

No need to check

Upvotes: 0

CD..
CD..

Reputation: 74096

Use ng-if:

<div ng-if="category === 'aa'">aa</div>
<div ng-if="category === 'bb'">bb</div>

Or:

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

Upvotes: 2

Related Questions