Open In App

Angular MDBootstrap Badges Component

MDBootstrap is a Material Design and bootstrap-based Angular UI library that is used to make attractive webpages with its seamless and easy-to-use component. In this article, we will know how to use Badges Component in Angular MDBootstap. 

The Badges Component is used to represent the text as a status indicator or number as a badge.



Properties:

Syntax:



<mdb-badge> Badge </mdb-badge>

Approach:

npm install
cd appname
ng serve

Project Structure: After complete installation, it will look like the following:

Project Structure

Example 1: This is the basic example that illustrates how to use the Badges component in Angular MDBootstrap.




<div id="gfg">
  <h2>
    GeeksforGeeks
    <mdb-badge color="green">Badge 1</mdb-badge>
  </h2>
  <h4>
    Angular MDBootstrap Badges Component
    <mdb-badge color="red">Badge 2</mdb-badge>
  </h4><br />
</div>




import { Component } from '@angular/core';
  
@Component({
  selector: 'my-app',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent{}




import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { BrowserAnimationsModule } 
    from '@angular/platform-browser/animations';
  
import { AppComponent } from './app.component';
import { MDBBootstrapModule } from 'angular-bootstrap-md';
import { FormsModule } from '@angular/forms';
  
@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    BrowserAnimationsModule,
    MDBBootstrapModule.forRoot(),
    FormsModule,
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule{}

Output:

 Angular MDBootstra Default Badges Component

Example 2: This example illustrates the Angular MDBootstrap Pill Badges Component.




<div id="gfg">
  <h2>
    GeeksforGeeks
    <mdb-badge pill="true" color="green">Badge 1</mdb-badge>
  </h2>
  <h4>
    Angular MDBootstrap Badges Component
    <mdb-badge pill="true" color="red">Badge 2</mdb-badge>
  </h4><br />
</div>




import { Component } from '@angular/core';
  
@Component({
  selector: 'my-app',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent{}




import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { BrowserAnimationsModule } 
    from '@angular/platform-browser/animations';
  
import { AppComponent } from './app.component';
import { MDBBootstrapModule } from 'angular-bootstrap-md';
import { FormsModule } from '@angular/forms';
  
@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    BrowserAnimationsModule,
    MDBBootstrapModule.forRoot(),
    FormsModule,
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule{}

Output:

Angular MDBootstrap Pill Badges Component

Reference: https://mdbootstrap.com/docs/angular/components/badges/


Article Tags :