After selecting a category, I attempted to change the color using "ng-style" in my HTML code. However, it seems that the color change is not taking effect.
This is the snippet from my HTML code:
<div ng-repeat="item in ListExpense" ng-class-odd="'item item-icon-left desc-expense a'" ng-class-even="'item item-icon-left desc-expense b'">
<i class="icon ion-ios-pricetags" ng-style="{'color': selectedColor[$index]}" ng-click="showPopover($event, $index, item.ExpenseId, item.CategoryId)"></i>
<div class="col description" ng-click="showEditExpense(item.ExpenseId)">{{ item.Title }}</div>
<div class="col cost" ng-bind="item.Amount | currency:'':0"></div>
</div>
This is the code for my popup:
<div id="popup">
<ion-scroll style="height: 190px;">
<label ng-repeat="item in ListCategory" for="{{item.Name}}">
<input type="radio"
ng-model="myCategory"
ng-value="item.CategoryId"
ng-click="closeInController(item.CategoryId, ItemId, paramDate)"
id="{{item.CategoryId}}"
name="category">
{{item.Name}}
<br>
</label>
</ion-scroll>
</div>
Additionally, this is the relevant section of my controller.js file for showing the category selection popup:
// Controller Popover tags expense
.controller('PopOver', function($scope, $ionicPlatform, $ionicPopover, Category, Expense) {
$ionicPlatform.ready(function() {
// Code Snippet Omitted for Brevity
$scope.showPopover = function($event, index, ExpenseId, CategoryId) {
console.log(CategoryId);
$scope.myCategory = CategoryId;
$scope.item_index = index;
$scope.ItemId = ExpenseId;
$scope.popover.show($event);//
}
$scope.closeInController = function(selectedItem, ExpenseId, paramDate, color, cindex) {
Expense.updateCategory(selectedItem, ExpenseId);
Expense.getByDate(paramDate).then(function(res) {
console.log(res);
$scope.ListExpense = res;
});
$scope.popover.hide();
$scope.selectedColor = {};
$scope.selectedColor[cindex] = color;
console.log(cindex + ' -- ' + color);
};
});
})
I encountered an error where 'undefined' values are being displayed. Can anyone assist me with this issue?
Thank you in advance!