[style.background-color]="activity.status == 'Pending' ? 'red' : 'green'"
or
[ngStyle]="{'backgroundColor': activity.status == 'Pending' ? 'red' : 'green' }"
For your rendering result see also In RC.1 some styles can’t be added using binding syntax
More Related Contents:
- Global Events in Angular
- How to show a loading spinner while waiting on an observable getting data from a service in Angular
- Why use “?” operator in template binding?
- angular2 manually firing click event on particular element
- How can I watch for changes to localStorage in Angular2?
- Angular 2 – How do I navigate to another route using this.router.parent.navigate(‘/about’)?
- Angular2 – Redirect to calling url after successful login
- async/await in Angular `ngOnInit`
- Connect Angular application with ReactJS app?
- How to make directives and components available globally
- Handling 401s globally with Angular
- Angular2 router keep query string
- Angular2 – Validate and submit form from outside
- In Angular, how to add Validator to FormControl after control is created?
- Getting Image from API in Angular 4/5+?
- Angular 2 Dynamically insert a component into a specific DOM node without using ViewContainerRef
- Angular 2 – Using Shared Service
- Angular 4 HttpClient Query Parameters
- Mat-table Sorting Demo not Working
- Can’t bind to ‘formControl’ since it isn’t a known property of ‘input’ – Angular2 Material Autocomplete issue
- fromPromise does not exist on type Observable
- Angular 4 call parent method in a child component
- Type casting within a template in Angular 2
- How to add Web Animations API polyfill to an Angular 2 project created with Angular CLI
- WARNING in budgets, maximum exceeded for initial
- How to declare a pipe globally to use in different modules?
- How to return value inside subscribe Angular 4
- Angular 2 / 4 / 5 – Ahead-of-time compilation how to
- Angular 8 ng-build throwing MIME error with cordova
- Angular 2 how to display .pdf file