How will you display different images based on the status being red, amber, or green?



How will you display different images based on the status being red, amber, or green?..

Answer / Rahul G. Momin

In AngularJS, you can use conditional statements in your HTML to show different images based on a specific status. Here's an example:

HTML:
```
<img ng-src="{{status === 'red' ? 'image_red.png' : (status === 'amber' ? 'image_amber.png' : 'image_green.png')}}" />
```

In this example, the `ng-src` directive sets the source of the image dynamically based on the value of the `status` variable. The ternary operator checks if the `status` is 'red', and if so, it shows the red image; otherwise, it checks if the `status` is 'amber', and if so, it shows the amber image. If neither condition is met, it shows the green image.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More AngularJS Interview Questions

What is react vs angular?

1 Answers  


What are AngularJS features?

1 Answers   SLK Software,


Explain the compilation process of angularjs?

1 Answers  


What does a router.navigate do?

1 Answers  


How to enable and disable buttons with using condition?

1 Answers  


How can we share data between controllers?

1 Answers  


How to create and use custom pipes? How to create a globally available custom pipe?

1 Answers  


What is token based authentication in angular 4?

1 Answers  


How to add css styles in angular 5/4 applications?

1 Answers  


What is difference between ng bind and expression?

1 Answers  


How do you share data between controllers in angularjs?

1 Answers  


What is .angular-cli.json. Where can I find it?

1 Answers  


Categories