0

i am new in Angular and using Angular 12 , i wanted to use Angular Material with bootsrap 4 , popper.js and Jquery , my goal is to be able to have the freedom to choose and combine in my components between boostrap and Angular Material , for example an angular material form and a boostrap navbar in the same component , so i am stuck with the configuration , i just runned npm install angular-material --save and have no idea about what is the next step since in most of tutorials they are importing a file of bootsrap with css extension while my bootsrap is with scss

so here my package.json file

{
  "name": "angular-info-school",
  "version": "0.0.0",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "watch": "ng build --watch --configuration development",
    "test": "ng test"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "~12.1.2",
    "@angular/common": "~12.1.2",
    "@angular/compiler": "~12.1.2",
    "@angular/core": "~12.1.2",
    "@angular/forms": "~12.1.2",
    "@angular/platform-browser": "~12.1.2",
    "@angular/platform-browser-dynamic": "~12.1.2",
    "@angular/router": "~12.1.2",
    "angular-material": "^1.2.3",
    "bootstrap": "^4.6.0",
    "jquery": "^3.6.0",
    "popper.js": "^1.16.1",
    "rxjs": "~6.6.0",
    "tslib": "^2.2.0",
    "zone.js": "~0.11.4"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~12.1.2",
    "@angular/cli": "~12.1.2",
    "@angular/compiler-cli": "~12.1.2",
    "@types/jasmine": "~3.8.0",
    "@types/jquery": "^3.5.6",
    "@types/node": "^12.11.1",
    "jasmine-core": "~3.8.0",
    "karma": "~6.3.0",
    "karma-chrome-launcher": "~3.1.0",
    "karma-coverage": "~2.0.3",
    "karma-jasmine": "~4.0.0",
    "karma-jasmine-html-reporter": "~1.7.0",
    "typescript": "~4.3.2"
  }
}

my angular.json:

{
  "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
  "cli": {
    "analytics": false
  },
  "version": 1,
  "newProjectRoot": "projects",
  "projects": {
    "angular-info-school": {
      "projectType": "application",
      "schematics": {
        "@schematics/angular:component": {
          "style": "scss"
        },
        "@schematics/angular:application": {
          "strict": true
        }
      },
      "root": "",
      "sourceRoot": "src",
      "prefix": "app",
      "architect": {
        "build": {
          "builder": "@angular-devkit/build-angular:browser",
          "options": {
            "outputPath": "dist/angular-info-school",
            "index": "src/index.html",
            "main": "src/main.ts",
            "polyfills": "src/polyfills.ts",
            "tsConfig": "tsconfig.app.json",
            "inlineStyleLanguage": "scss",
            "assets": [
              "src/favicon.ico",
              "src/assets"
            ],
            "styles": [
              "src/assets/scss/_variableoverrides.scss",
              "src/styles.scss"
            ],
            "scripts": [
              "node_modules/jquery/dist/jquery.min.js",
              "node_modules/popper.js/dist/umd/popper.min.js",
              "node_modules/bootstrap/dist/js/bootstrap.min.js"
            ]
          },
          "configurations": {
            "production": {
              "budgets": [
                {
                  "type": "initial",
                  "maximumWarning": "500kb",
                  "maximumError": "1mb"
                },
                {
                  "type": "anyComponentStyle",
                  "maximumWarning": "2kb",
                  "maximumError": "4kb"
                }
              ],
              "fileReplacements": [
                {
                  "replace": "src/environments/environment.ts",
                  "with": "src/environments/environment.prod.ts"
                }
              ],
              "outputHashing": "all"
            },
            "development": {
              "buildOptimizer": false,
              "optimization": false,
              "vendorChunk": true,
              "extractLicenses": false,
              "sourceMap": true,
              "namedChunks": true
            }
          },
          "defaultConfiguration": "production"
        },
        "serve": {
          "builder": "@angular-devkit/build-angular:dev-server",
          "configurations": {
            "production": {
              "browserTarget": "angular-info-school:build:production"
            },
            "development": {
              "browserTarget": "angular-info-school:build:development"
            }
          },
          "defaultConfiguration": "development"
        },
        "extract-i18n": {
          "builder": "@angular-devkit/build-angular:extract-i18n",
          "options": {
            "browserTarget": "angular-info-school:build"
          }
        },
        "test": {
          "builder": "@angular-devkit/build-angular:karma",
          "options": {
            "main": "src/test.ts",
            "polyfills": "src/polyfills.ts",
            "tsConfig": "tsconfig.spec.json",
            "karmaConfig": "karma.conf.js",
            "inlineStyleLanguage": "scss",
            "assets": [
              "src/favicon.ico",
              "src/assets"
            ],
            "styles": [
              "src/assets/scss/_variableoverrides.scss",
              "src/styles.scss"
            ],
            "scripts": [
              "node_modules/jquery/dist/jquery.min.js",
              "node_modules/popper.js/dist/umd/popper.min.js",
              "node_modules/bootstrap/dist/js/bootstrap.min.js"
            ]
          }
        }
      }
    }
  },
  "defaultProject": "angular-info-school"
}

my style.scss

/* You can add global styles to this file, and also import other style files */
@import "./assets/scss/variableoverrides";
@import "../node_modules/bootstrap/scss/bootstrap.scss";

I saw answers here but they are not the same version of bootstrap and angular. i hope that this is possible and it will bo so good to have full freedom to combine between everything

  • for BS: https://www.techiediaries.com/angular-bootstrap/ or https://stackoverflow.com/questions/37649164/how-to-add-bootstrap-to-an-angular-cli-project for AM: https://material.angular.io/guide/getting-started you can follow the instructions – jo-chris Jul 20 '21 at 11:07
  • Nothing stops you from combining all these libraries with Angular. However, I see that you installed a wrong package than the one you expected `angular-material` instead of `@angular/material`. `ng add @angular/material` - running this command will set up `@angular/material` in your project. – Tsvetan Ganev Jul 20 '21 at 11:08
  • @jo-chris you did not understand the question , boostrap is working fine with me and alrady installed , the question is how to be able to configure the existence of angular material without having problems because it can lead to problems when using angular material with boostrap , my question is what should i do to make them work in the same time and avoid any kind of problems of making them working together – Road to engineering Jul 20 '21 at 11:11
  • @TsvetanGanev your comment is vey useful , i will try it and see the results – Road to engineering Jul 20 '21 at 11:14
  • where to put exactly angular-material in angular.json ? under bootsrap in scripts or on top of it? – Road to engineering Jul 20 '21 at 11:16
  • You don't need that package at all. First remove it: `npm uninstall angular-material`. Then add `@angular/material` (the official Google implementation of material design) by running: `ng add @angular/material` - this will configure your `angular.json` file and you'll be ready to go. – Tsvetan Ganev Jul 20 '21 at 11:18

0 Answers0