1

I have included my component's .css file in this manner `

angular.
  module('home').
  component('home', {
    templateUrl: 'home/home.template.html',
    styleUrls: 'home/home.component.css'
    
    
  });

` But it seems that the stylesheet is not getting applied. What is the right way of including the stylesheet? This is the folder structure.

2
  • just wondering why you are writing angular 2 in javascript instead of typescript. Also, the way you have pasted the code makes it look like angular.js, not angular 2+ guidelines Commented Sep 2, 2021 at 6:36
  • I have a project to be built in angular 1.x which includes .js files . Commented Sep 2, 2021 at 6:46

4 Answers 4

0

You have to put square brackets on the url like this: styleUrls: ['home/home.component.css']

angular.
  module('home').
  component('home', {
    templateUrl: 'home/home.template.html',
    styleUrls: ['home/home.component.css']
    
    
  });

Sign up to request clarification or add additional context in comments.

Comments

0

styleUrls accepts an array

styleUrls: ['home/home.component.css']

1 Comment

I tried this but didn't make a difference. Css isn't getting applied.
0
I faced the same problem and then I found the answer. just add this line inside the component declaration :

encapsulation: ViewEncapsulation.None

for example, 

@Component({
  templateUrl: './usertradedata.component.html',
  animations: [appModuleAnimation()],
  styleUrls:['./usertradedata.component.css'],
  encapsulation: ViewEncapsulation.None
})

Comments

0

I think you mean this click link here

"styles": [
"../node_modules/angular2-busy/build/style/busy.css",
"styles.css"
],

in .angular-cli.json

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.