As a newcomer to Angular, I am looking to add animation to a div element using ng-click within an ng-repeat loop. Here is what I have attempted:
app.js
var app = angular.module( 'app', [] );
app.controller('appController', function($scope) {
$scope.items = [
{"id": "id1", "name": "Name 1"},
{"id": "id2", "name": "Name 2"},
{"id": "id3", "name": "Name 3"}
];
$scope.selectedStyle = {"background-color": "blue", "color": "white"};
$scope.selectedItem = $scope.items[0];
$scope.selectItem = function(item) {
$scope.selectedItem = item;
}
});
app.html
<div ng-app="app" ng-controller="appController">
<table class=table>
<tbody>
<tr ng-repeat="item in items" ng-click="selectItem(item)" ng-style="item.id === selectedItem.id && selectedStyle">
<td>
{{item.id}}
</td>
</tr>
</tbody>
</table>
<div class="item-body">
{{selectedItem.name}}
</div>
</div>
I am trying to implement a fade-in transition effect on the "item-body" div as the item changes. Despite searching online, I have been unable to find a suitable solution. Any assistance would be greatly appreciated.