I am trying to dynamically set the background image for the ion-content
element. How can I achieve this? If it were a CSS class, I could simply use [class]="cssClassName"
and change the class name in the TypeScript file. But in this case, how can I accomplish that?
.ts
ngOnInit() { this.initialize(); }
initialize() {
switch (environment.hotelEnvironment.hotelName) {
case "com1":
// has background
break;
case "com2":
//no background
break;
default:
}
}
.html
<ion-content>
</ion-content>
.scss
ion-content {
--background: url('/assets/img/com/background/background.png') no-repeat 100% 100%;
}