Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

condition for load styleUrls in component angular

Tags:

angular

I want use of multi css in styleUrls

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: [condition 'if' for Which load css]
})

i tired

like image 840
Morteza Moradi Avatar asked Dec 05 '25 12:12

Morteza Moradi


1 Answers

You can use a ternary operator inside:

const url1 = './foo.css';
const url2 = './bar.css';

let condition = true

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: [condition ? url1 : url2]
})
like image 141
mchl18 Avatar answered Dec 07 '25 10:12

mchl18



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!