I would like to dynamically assign a class to a specific cell in a table.
An object in "cols" could look like this:
{condition: '{\'prio-high\': priority == 0}', noCondition: 'prio-high'}
I made sure that priority is indeed == 0.
Is this even possible? The following example works just fine. It just doesn't seem to work if I want to work with conditions.
Example:
.html
.condition{background-color: red}
.noCondition{background-color: blue}
.someRandomOtherCondition{background-color: orange}
{{ o.name }} has priority {{ o.prio }}
.ts
export class AppComponent {
info = [
{object1: 'noCondition'},
{object2: '{\'condition\': prio == 0}'}
]
objects = [
{
name: 'object1',
prio: 0, //imagine this number is being dynamically assigned and we don't know the value beforehand
template: 'noCondition'
},
{
name: 'object3',
prio: 0, //imagine this number is being dynamically assigned and we don't know the value beforehand
template: 'someRandomOtherCondition'
},
{
name: 'object2',
prio: 1, //imagine this number is being dynamically assigned and we don't know the value beforehand
template: '{\'condition\': prio == 1}'
}
];
}
if you run this example you will see that object2 is never being formatted properly as it should.
stackblitz:
https://stackblitz.com/edit/angular-dani1p
JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)