6

I am using ngx-bootstrap and I need to import one css file into my component, like this:

Load it from node_modules/ngx-bootstrap/datepicker/bs-datepicker.css via package bundler like Angular CLI, if you're using one.

(this is on component's documentation).

I don't know how to load the bs-datepicker.css via package bundler.

What I have tried is:

  • On my component, I tried to load:

styleUrls: ['node_modules/ngx-bootstrap/datepicker/bs-datepicker.css']

(no success, this wasn't found).

The file is in this directory:

C:\DEV\senai-5s-webapp\node_modules\ngx-bootstrap\datepicker\bs-datepicker.css

2
  • Are you using angular-cli? Commented Feb 26, 2018 at 15:09
  • Yes, I am using! @David Commented Feb 26, 2018 at 15:10

2 Answers 2

7

In your .angular-cli.json file, modify the style property to add the css file besides your other styles (you should already have styles.css by default)

"styles": [
  "styles.css",
  "../node_modules/ngx-bootstrap/datepicker/bs-datepicker.css"
],
Sign up to request clarification or add additional context in comments.

Comments

1

Actually you can import them to in your .angular-cli.json here

  "styles": [
        "../node_modules/ngx-bootstrap/datepicker/bs-datepicker.css,
         ...
      ],

2 Comments

Usually there is no need for view encapsulation, if the styles are not overlapping.
Yes, Encapsulation.None means that the component styles will leak to child elements Here, styles are applied at the application level, so there is no need for that

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.