Take a look at this code snippet:
<script src="angular.min.js"></script>
<script src="jquery-1.6.4.js"></script>
<script type="text/javascript">
var app = angular.module('myApp', []);
app.controller("myController", function ($scope) {
$scope.names = [
{
id: 1,
name: 'Michael',
age: 12
}
];
});
</script>
Here is the section of my HTML file associated with this:
<body ng-app="myApp" ng-controller="myController">
<div ng-switch on="{{names[0].id}}">
<div ng-switch-when="1"><img src="/images/id1.jpg"></div>
<div ng-switch-when="2"><img src="/images/id2.jpg"></div>
</div>
</body>
I am trying to display images based on the ID, but it's not working as expected.
Do you have any ideas or suggestions for alternative methods to achieve this functionality?