V
V
Vladimir2017-04-26 22:12:24
css
Vladimir, 2017-04-26 22:12:24

How to change styles in Angular 2?

Good day! When a component is declared (for example):

@Component({
  selector: 'quest-summary',
  template: `
    {{ someName }}
  `,
  styleUrls:  ['./quest-summary.component.css']
})

Interested in whether it is possible in Angular 2 to use expressions like "{{ someName }}" in css styles that are connected using styleUrls. For example, to control some things like fonts, colors, etc. from the admin panel, not through the code. Thanks in advance for your replies!
PS ngClass and ngStyle not to offer, purely expressions inside the css code are of interest.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ivan Stroykin, 2017-04-26
@MasterGerold

You can't do that. If you want the appearance to change depending on some user settings, this is done (as a practical option):
in the layout component, which "wraps" all other components, write a substitution class that will change depending on the user's choice. And in styles, write the main styles for all +, depending on the selected class, that is:

.selected-class-2 h1 {
  color: red;
}

There can be several such classes, and all styles are well cached by browsers and the design change will be instant. Thus, you can create an unlimited number of appearances in one application.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question