I am trying to apply some CSS to a particular section containing a certain JSON value.
Lets say I want to add a red background to a text containing the words "main article".
I have managed to hide the value by using a pipe like below
@Pipe({
name: 'exclusionfilter',
pure: false
})
@Injectable()
export class ExclusionFilterPipe implements PipeTransform {
transform(value: any) {
if((value!=null)&& (value.toLowerCase().indexOf("main article") != -1)){
return '';
}
else return value;
}
}
and the markup is like this
<h2 class="heading">{{ info.title | exclusionfilter }}</h2>
I want to apply some CSS to the h2 whenever the value is "main article".
I dont think that this approach is clean, but cant think of alternatives