在 div class 的按钮下拉菜单中获取背景颜色 Angular
get background color on button dropdown of div class dropdown on Angular
我尝试根据用户selected.when你select的值在标签'a'的下拉菜单中获取颜色select列表按钮它的颜色变化跟随列表我试过的代码是:
app.component.html
<div class="dropdown dd">
<button class="btn dropdown-toggle" type="button" id="dropdownMenuButton"
data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" >
<i class="{{ getPriorityIcon(ticket.priority) }} text-left"></i>{{ticket.priority}}
</button>
<div class="dropdown-menu w-100" aria-labelledby="dropdownMenuButton">
<a *ngFor="let priority of Prioritys" class="dropdown-item"
(click)="changePriority(ticket.id, priority.name)" >
<i class="{{priority.icon}}" value="priority.name"></i> {{priority.name}} </a>
</div>
</div>
app.component.ts
Prioritys = [
{ name: 'Low', icon: 'fas fa-square mx-2', value: '#2ED0B9' },
{ name: 'Medium', icon: 'fas fa-circle mx-2', value: '#FFBE96'},
{ name: 'High', icon: 'fas fa-star mx-2', value: '#2ED0B9'},
{ name: 'Critical', icon: 'fas fa-fire mx-2', value: '#2ED0B9' }
];
您需要更改的第一件事是 *ngFor 列表,而不是类型,您需要更改为优先级。
<a *ngFor="let type of Prioritys "/>
而对于颜色,你可以使用 ng-style
<span ng-style='{color: type.value}'>{{type.value}}</span>
我尝试根据用户selected.when你select的值在标签'a'的下拉菜单中获取颜色select列表按钮它的颜色变化跟随列表我试过的代码是:
app.component.html
<div class="dropdown dd">
<button class="btn dropdown-toggle" type="button" id="dropdownMenuButton"
data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" >
<i class="{{ getPriorityIcon(ticket.priority) }} text-left"></i>{{ticket.priority}}
</button>
<div class="dropdown-menu w-100" aria-labelledby="dropdownMenuButton">
<a *ngFor="let priority of Prioritys" class="dropdown-item"
(click)="changePriority(ticket.id, priority.name)" >
<i class="{{priority.icon}}" value="priority.name"></i> {{priority.name}} </a>
</div>
</div>
app.component.ts
Prioritys = [
{ name: 'Low', icon: 'fas fa-square mx-2', value: '#2ED0B9' },
{ name: 'Medium', icon: 'fas fa-circle mx-2', value: '#FFBE96'},
{ name: 'High', icon: 'fas fa-star mx-2', value: '#2ED0B9'},
{ name: 'Critical', icon: 'fas fa-fire mx-2', value: '#2ED0B9' }
];
您需要更改的第一件事是 *ngFor 列表,而不是类型,您需要更改为优先级。
<a *ngFor="let type of Prioritys "/>
而对于颜色,你可以使用 ng-style
<span ng-style='{color: type.value}'>{{type.value}}</span>