LoginSignup
1
2

More than 3 years have passed since last update.

【Angular】プロジェクトへBootstrapの適用方法【忘備録】

Posted at

Angular プロジェクト作成

> ng new angular-bootstrap

Angular プロジェクトへ移動

> cd angular-bootstrap

Angular プロジェクトへBootstrapのインストール

> npm install --save bootstrap
> npm install --save @ng-bootstrap/ng-bootstrap
> ng add @angular/localize

設定ファイルの書き換え

angular.json
"styles": [
  "src/styles.css",
  "./node_modules/bootstrap/dist/css/bootstrap.min.css"
],

app.module.tsへの追記

app.module.ts
...
import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
@NgModule({
  ...
  imports: [
    BrowserModule,
    AppRoutingModule,
    NgbModule,
  ],
  ...
})
export class AppModule { }

app.component.htmlの書き換え

app.component.html
<div class="form1">
  <div class="form-group">
    <input 
      type="text" 
      class="form-control"/>
  </div>
  <button 
    class="btn btn-primary">OK</button>
</div>

おしまい!

1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2