Angular 2: is the style relative to the current component?

I am facing some problems to add style to my angular 2 component using styleUrls.

Here is how I use it:

path /main.component.ts

@Component({
    selector: 'app-view',
    styleUrls: ['./styles/style.css'],
    template: //...
})

path / styles / style.css

.main-wrapper {
  position: absolute;
  top: 0;
  bottom: 0;
  right: 0;
  left: 0;
  background: red; }

And nothing happens in my browser. I tried with:

  • absolute path
  • path relative to the root component.

I also tried:

  • to write this using different type syntaxes './styles/style.css','styles/style.css'
  • to move mine style.cssnext to my component.

But I can’t make it work.

+2
source share
1 answer

styleUrls. scss. !

, :

  • mycomponent.ts
  • mycomponent.html
  • mycomponent.scss
0

All Articles