2016-07-16 3 views
5

Angular-CLI(Angular2 RC4)プロジェクトにng-bootstrapを追加するにはどうすればいいですか?Angular-CLI(Broccoli版)プロジェクトにng-bootstrapを追加するにはどうすればいいですか?

具体的に

:私は私のnode_modulesフォルダから私の角度-CLIプロジェクトに縮小さ.cssファイルを追加する必要がありますどのように

  1. これをangular-cli-build.jsに追加する必要がありますか?
  2. タイピングを追加する必要がありますか?
  3. 私はプロジェクトディレクトリと型に移動はい、あなたがangular-cli-build.jsファイル まずでvendorNpmFilesから参照することで、あなたのCSSファイルのすべてを追加する必要が

答えて

5

を/src/system-config.tsためにそれを追加する必要がありますか今お使いのsrc /システム-confのを開く

npm install --save @ng-bootstrap/ng-bootstrap 

、あなたの角度-CLI-build.jsを開き、

vendorNpmFiles: [ 
    'systemjs/dist/system-polyfills.js', 
    'systemjs/dist/system.src.js', 
    'zone.js/dist/**/*.+(js|js.map)', 
    'es6-shim/es6-shim.js', 
    'reflect-metadata/**/*.+(ts|js|js.map)', 
    'rxjs/**/*.+(js|js.map)', 
    '@angular/**/*.+(js|js.map)', 
    'angularfire2/**/*.js', 
    'firebase/*.js', 
    '@ng-bootstrap/ng-bootstrap/**/*.+(js|js.map)' 
] 

この行を追加します。あなたには、いくつかを追加する必要がある場合ig.ts、実際には、はいも上記@pdのfarhadによって答えが、私はその一つに、いくつかの説明を与えたい

const map: any = { 
    '@ng-bootstrap/ng-bootstrap': 'vendor/@ng-bootstrap/ng-bootstrap' 
}; 

const packages: any = { 
    '@ng-bootstrap/ng-bootstrap': { 
    defaultExtension: 'js', 
    main: 'index.js' 
    }, 
    '@ng-bootstrap/ng-bootstrap/accordion': { 
    defaultExtension: 'js', 
    main: 'index.js' 
    }, 
    '@ng-bootstrap/ng-bootstrap/alert': { 
    defaultExtension: 'js', 
    main: 'index.js' 
    }, 
    '@ng-bootstrap/ng-bootstrap/buttons': { 
    defaultExtension: 'js', 
    main: 'index.js' 
    }, 
    '@ng-bootstrap/ng-bootstrap/carousel': { 
    defaultExtension: 'js', 
    main: 'index.js' 
    }, 
    '@ng-bootstrap/ng-bootstrap/collapse': { 
    defaultExtension: 'js', 
    main: 'index.js' 
    }, 
    '@ng-bootstrap/ng-bootstrap/dropdown': { 
    defaultExtension: 'js', 
    main: 'index.js' 
    }, 
    '@ng-bootstrap/ng-bootstrap/pagination': { 
    defaultExtension: 'js', 
    main: 'index.js' 
    }, 
    '@ng-bootstrap/ng-bootstrap/popover': { 
    defaultExtension: 'js', 
    main: 'index.js' 
    }, 
    '@ng-bootstrap/ng-bootstrap/progressbar': { 
    defaultExtension: 'js', 
    main: 'index.js' 
    }, 
    '@ng-bootstrap/ng-bootstrap/rating': { 
    defaultExtension: 'js', 
    main: 'index.js' 
    }, 
    '@ng-bootstrap/ng-bootstrap/tabset': { 
    defaultExtension: 'js', 
    main: 'index.js' 
    }, 
    '@ng-bootstrap/ng-bootstrap/timepicker': { 
    defaultExtension: 'js', 
    main: 'index.js' 
    }, 
    '@ng-bootstrap/ng-bootstrap/tooltip': { 
    defaultExtension: 'js', 
    main: 'index.js' 
    }, 
    '@ng-bootstrap/ng-bootstrap/typeahead': { 
    defaultExtension: 'js', 
    main: 'index.js' 
    } 
}; 
+0

それは角度UIチームによって書かれたNG-ブートストラップを求めているので、答えを編集。 Valor Softwareのng2-bootstrapについては問いません。違いについてはこちらをご覧ください。 https://www.reddit.com/r/Angular2/comments/4s3kkx/what_is_the_difference_between_ngbootstrap/ –

+0

'precompile:[NGB_PRECOMPILE]を設定すると、@ pd-farhad次のエラーが表示されます。bootstrap-angular/tmp/broccoli_type_script_compiler-input_base_path -djYaKive.tmp/0/SRC /アプリ/ app.component.ts(8、3)型の引数「{モジュールID:文字列。セレクタ:文字列;ディレクティブ:(type of NgbAlert | type of NgbDismissibleAlert)[...'はタイプ' {selector ?: string;のパラメータに代入不可能です。入力?:文字列[];出力?:文字列[];プロパティ?:文字列[];イベント?: strin ... '。 オブジェクトリテラルは既知のプロパティのみを指定することができ、 'プリコンパイル'は型 '{selector ?: string;入力?:文字列[]; outp –

2

を書きます角度CLIでサードパーティのライブラリ角度CLIではなく、ベンダーのフォルダからすべてのファイルを取ったので、あなたは、角度-CLI-build.jsファイルにそのサードパーティのライブラリの参照を追加している必要がありますnode_modulesフォルダのため、cli-buildファイルにライブラリのエントリを追加すると(たとえば、あなたのケースではng-bootstrap)そのライブラリのコピーをangi cliのベンダフォルダに作成します。私たちのプロジェクトで利用可能です。そう

How should I add the minified .css from my node_modules folder to my angular-cli project?

あなたは、ベンダーのフォルダに取得するために、system-cli-build.jsファイル内にそのファイル/ライブラリの参照を与える必要があります。

Do I have to add it to angular-cli-build.js

はい、その強制的なあなたも、パブリックフォルダにそのファイルをドロップすることができますよりも、それだけで単一のファイルの場合はないライブラリですが、場合。それはあなたに依存します。

Do I have to add the typings?

それほど多くの義務はありません。

が、これは多くをクリア願っています!

+0

非常によく説明されています。この説明をあまりにも謝ります。なぜそれがタイピングに追加することはそれほど義務ではないのか分かりますか? AngularFire2を追加するには、タイピングを追加する必要があります。それで、タイピングに追加するかどうか決定する要因は何ですか? –

+0

ありがとうございましたあなたの感謝は私のためにたくさんのことを意味します:)申し訳ありません私はあなたが私の既存の回答 –

関連する問題