valor-software / ng2-tree

Angular tree component
http://valor-software.com/ng2-tree/index.html
MIT License
348 stars 190 forks source link

Can'not import tree styles #163

Open davayd opened 7 years ago

davayd commented 7 years ago

I've create a component station.component.ts with his station.component.css file styles and trying to import ng2-tree styles like: 1) in station.component.css

@import '~ng2-tree/styles.css'; 2) in station.component.ts

styleUrls: ['./stations.component.css', '../../../node_modules/ng2-tree/styles.css']

But none of them not working. Guide me to the right version

Doctorr commented 7 years ago

If your station.component.css is residing in the src/app folder then you would @import url("../../node_modules/ng2-tree/styles.css"); This is for your css file. Would need to see your file structure to be 100% sure.

davayd commented 7 years ago

Not working :|. I build NetCore2 + Angular4 and structure of my app looks similar like in this project https://github.com/asadsahi/AspNetCoreSpa. I tried to connect tree style into .angular-cli.json, but this method also did not work

"apps": [ { "root": "ClientApp", "styles": [ "../node_modules/ng2-tree/styles.css" ] } ]

Jiehong commented 6 years ago

I'm experiencing the same issue actually, but on a different angular 5 project. Even with @import url("../../node_modules/ng2-tree/styles.css");, no style is applied.

I can only force the style with some :host ::ng-deep on each class :/

Version used: 2.0.0-rc.4

Jiehong commented 6 years ago

Ah, perhaps this doesn't work as this is a css style, and not a scss one!

ghost commented 6 years ago

@davayd If you want to overwrite the default styling (especially if you don't want node_modules in source control) copy the styles.css file from ng2-tree into your project and use an @include in your global style sheet to include it. This will also fix your issue if you just want the default styling.

PS. The issue your having is to do with "style scope". See here: https://angular.io/guide/component-styles

@rychkog Not a bug

rychkog commented 6 years ago

@ctolene Thanks! This should be documented