gpt4 book ai didi

css - ng 风格不起作用

转载 作者:太空宇宙 更新时间:2023-11-03 17:43:30 25 4
gpt4 key购买 nike

我尝试在选择类别后更改颜色,我尝试使用“ng-style”。但它不起作用。

这是我的代码 html:

<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'">
<!-- this to change color -->
<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>

这是我的弹出代码:

<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>

这是我的 contoller.js,并显示弹出窗口以选择类别:

 // Controller Popover tags expense
.controller('PopOver', function($scope, $ionicPlatform, $ionicPopover, Category, Expense) {
$ionicPlatform.ready(function() {
$scope.myFormCat = {};
$scope.myFormCat.name = "Audit Form";
$scope.myFormCat.submitCategory = function(ExpenseId, event) {
var theCategory = $scope.myFormCat.Category;
if (theCategory === undefined) {
//
} else {
var cat = {};
cat.Name = theCategory;
cat.Type = 'D';
Category.add(cat).then(function(res) {
var lastId = res.insertId;
Expense.updateCategory(lastId, ExpenseId);
});
Category.all('D').then(function(res) {
$scope.ListCategory = res;
});

$scope.myFormCat.Category = '';

$scope.popover.hide();
}
};

var d = new Date();
var mm = d.getMonth();
var dd = d.getDate();
var yy = d.getFullYear();


Category.all('D').then(function(res) {
console.log(res);
console.log("inilah " + res.length);
if (res.length > 0) {
$scope.ListCategory = res;
} else {

}
})

//beware of month is month + 1
Expense.totalPerCategory(mm+1, yy).then(function(res) {
console.log(res);
$scope.TagColor = {};
for (i = 0; i < res.length; i++) {
$scope.TagColor[res[i].CategoryId] = {
color: res[i].BgColor,
label: res[i].CategoryName
};
}
})

$ionicPopover.fromTemplateUrl('templates/popoversss.html', {
scope: $scope,
}).then(function(popover) {
$scope.popover = popover;
});

$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);
};

});
})

我收到错误未定义 -- 未定义。谁能帮帮我?

提前致谢

最佳答案

尝试更改您的代码:

Expense.totalPerCategory(mm+1, yy).then(function(res) {
console.log(res);
$scope.ListExpense = [];
for (i = 0; i < res.length; i++) {
$scope.ListExpense.push({
color: res[i].BgColor
};
}
})

关于css - ng 风格不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28688025/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com