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 |
What is react vs angular?
What are AngularJS features?
Explain the compilation process of angularjs?
What does a router.navigate do?
How to enable and disable buttons with using condition?
How can we share data between controllers?
How to create and use custom pipes? How to create a globally available custom pipe?
What is token based authentication in angular 4?
How to add css styles in angular 5/4 applications?
What is difference between ng bind and expression?
How do you share data between controllers in angularjs?
What is .angular-cli.json. Where can I find it?