Dean Chalk
Dean Chalk

Reputation: 20471

Setting up for the first time, but not working

I have followed your install instructions to the letter, including setting up my angular module files correctly.

I have cut and pasted code from your demo into my app.component.html file as below

<ngb-tabset>
  <ngb-tab title="Simple">
    <ng-template ngbTabContent>
      <p>Raw denim you probably haven't heard of them jean shorts Austin. Nesciunt tofu stumptown aliqua, retro synth
      master cleanse. Mustache cliche tempor, williamsburg carles vegan helvetica. Reprehenderit butcher retro keffiyeh
      dreamcatcher synth. Cosby sweater eu banh mi, qui irure terry richardson ex squid. Aliquip placeat salvia cillum
      iphone. Seitan aliquip quis cardigan american apparel, butcher voluptate nisi qui.</p>
    </ng-template>
  </ngb-tab>
  <ngb-tab>
    <ng-template ngbTabTitle><b>Fancy</b> title</ng-template>
    <ng-template ngbTabContent>Food truck fixie locavore, accusamus mcsweeney's marfa nulla single-origin coffee squid.
      <p>Exercitation +1 labore velit, blog sartorial PBR leggings next level wes anderson artisan four loko farm-to-table
      craft beer twee. Qui photo booth letterpress, commodo enim craft beer mlkshk aliquip jean shorts ullamco ad vinyl
      cillum PBR. Homo nostrud organic, assumenda labore aesthetic magna delectus mollit. Keytar helvetica VHS salvia
      yr, vero magna velit sapiente labore stumptown. Vegan fanny pack odio cillum wes anderson 8-bit, sustainable jean
      shorts beard ut DIY ethical culpa terry richardson biodiesel. Art party scenester stumptown, tumblr butcher vero
      sint qui sapiente accusamus tattooed echo park.</p>
    </ng-template>
  </ngb-tab>
  <ngb-tab title="Disabled" [disabled]="true">
    <ng-template ngbTabContent>
      <p>Raw denim you probably haven't heard of them jean shorts Austin. Nesciunt tofu stumptown aliqua, retro synth
      master cleanse. Mustache cliche tempor, williamsburg carles vegan helvetica. Reprehenderit butcher retro keffiyeh
      dreamcatcher synth. Cosby sweater eu banh mi, qui irure terry richardson ex squid. Aliquip placeat salvia cillum
      iphone. Seitan aliquip quis cardigan american apparel, butcher voluptate nisi qui.</p>
    </ng-template>
  </ngb-tab>
</ngb-tabset>

however, I get this when I run up the site in localhost:

enter image description here

So something isnt right with the setup.

I created a brand new Angular app with angular-cli. the angular version is 4.0.0

Thanks for your help

Upvotes: 0

Views: 429

Answers (4)

Brian Lowe
Brian Lowe

Reputation: 4943

I tripped over this too.

It's clear that ng-bootstrap is a replacement for the js which bootstrap brings in when you bring in the bootstrap css, but it's not clear how to bring in the bootstrap css without the unwanted js, or that bringing in ng-bootstrap without the associated css won't have the desired effect.

Here's what I did...

at the terminal:
npm install [email protected] --save
brings in the bootstrap 4 css (probably updated by the time you read this) along with the corresponding bootstrap js and a dependency on jquery, which you'll just have to ignore.

npm install @ng-bootstrap/ng-bootstrap --save
brings in the angular components which make use of the bs4 styles.

In angular-cli.json (you are using angular-cli aren't you?):
"styles": [ "styles.css" ],
becomes

"styles": [ "./../node_modules/bootstrap/dist/css/bootstrap.min.css", "styles.css" ],
to have webpack include the bootstrap styles along with your custom styles.

Then add the imports as described in the getting started doc.

Upvotes: 2

jasa
jasa

Reputation: 11

J just use url(bootstrap official website): and it worked!

Upvotes: 0

Pablo Oliva
Pablo Oliva

Reputation: 767

ng-bootstrap provides directives that you can use, but it does not include the Bootstrap CSS for styling. The instructions for getting started mention that there is a required dependency on Bootstrap CSS, and it is not explicit but implied that you must include the Bootstrap CSS in your application. This is just to clarify that there is a difference between the use of the directives and the use of the CSS for styling. You do not need to use ng-bootstrap if you will just be using Bootstrap for styling, formatting, layout, etc.

Upvotes: 2

Dean Chalk
Dean Chalk

Reputation: 20471

OK, I've found a hack to get it working, I have added the following line to my angular app's main css files

@import '~bootstrap/dist/css/bootstrap.min.css';

This fixes the issues, so it seems like somehow the ng-bootstrap package is failing to hookup the css somehow.

Thanks anyway for everyones help

Upvotes: 2

Related Questions