Code Monkey home page Code Monkey logo

ng2-bootstrap's Introduction

ng2-bootstrap npm version npm downloads

Native Angular2 directives for Bootstrap, works with Bootstrap 3 and 4-alfa

Follow me at twitter to be notified about new releases. Angular 2 Style Guide Build Status Code Climate Join the chat at https://gitter.im/valor-software/ng2-bootstrap Dependency Status devDependency Status

Throughput Graph

Usage & Demo

http://valor-software.github.io/ng2-bootstrap/

If you need more modules check here

Starter packages

Hint: simpliest way to add styles is a CDN:

<!-- index.html -->
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet">

With system.js: angular2-quickstart

  • install ng2-bootstrap and typings for moment.js
  npm install ng2-bootstrap --save
  # Install typings from NPM. Ambient typings will not help
  typings install moment --save
  • add some code
  <!-- src/app/home/home.html -->
  <alert type="info">Hello from ng2-bootstrap  {{ date.toDateString() }}</alert>
  <div style="display:inline-block; min-height:290px;">
    <datepicker [(ngModel)]="date" showWeeks="true"></datepicker>
  </div>
  /* src/app/home/home.ts */
  import {Alert, DATEPICKER_DIRECTIVES} from 'ng2-bootstrap/ng2-bootstrap';
  ...
  @Component({
    directives: [
      ...
      Alert, DATEPICKER_DIRECTIVES
      ]
  })
  export class Home {
    date: Date = new Date();
  }
  • hint: see quickstart section below for samples
  • just add link to ng2-bootstrap system.js bundle to index.html like in angular2-quickstart
  • and moment.js map in system.js configuration

Install from npm

npm i ng2-bootstrap --save

Install from CDN

Check cdnjs to include ng2-bootstrap as system.js bundle

<script src="https://cdnjs.cloudflare.com/ajax/libs/ng2-bootstrap/x.x.x/ng2-bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet">

Quick start

Hint: you can just clone angular2-quickstart

If you are following Angular2 5 min quickstart guide, just add one line

<!-- index.html -->
<script src="node_modules/ng2-bootstrap/bundles/ng2-bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet">

As for now datepicker is using moment.js to format date, so please update system.js config to contain mapping:

<!-- index.html -->
  System.config({
    packages: {
      app: {
        format: 'register',
        defaultExtension: 'js'
      }
    },
    map: {
      moment: 'node_modules/moment/moment.js'
    }
  });

And update your app.component.ts to have following content:

import {Component} from 'angular2/core';
import {Alert} from 'ng2-bootstrap/ng2-bootstrap';

@Component({
  selector: 'my-app',
  directives: [Alert],
  template: `<alert type="info">ng2-bootstrap hello world!</alert>`
})
export class AppComponent {
}

And you are ready to go! :)

API

Check demo for API documentation

Contribution

Please read central ng2 modules readme for details, plans and approach and welcome :)

Credits

Crossbrowser testing sponsored by Browser Stack Browser Stack

ng2-bootstrap's People

Contributors

amanwebdev avatar betrozov avatar buchslava avatar ciriarte avatar edinfazlic avatar erodozer avatar greenkeeperio-bot avatar haolong7 avatar jimthedev avatar jkuri avatar korel-san avatar krzysztofsaja avatar linusbrolin avatar louisscruz avatar miqmago avatar mkjeff avatar natali-abyss avatar nathanwalker avatar nolanus avatar olivierceulemans avatar rkintzi avatar rluba avatar ryzy avatar valorkin avatar yannickadam avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.