Angular Bootstrap collapse

Bootstrap collapse plugin allows you to toggle content on your pages with a bit of JavaScript and some classes. A flexible plugin that utilizes a handful of classes for easy toggle behavior.


Basic examples

Add (click)="test.toggle()" mdbWavesEffect to the button tag.

Place the collapse content <div> in the parent <div> and add [collapse]="isCollapsed" #test="bs-collapse" inside.

Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident.


<button class="btn btn-primary waves-light" type="button" (click)="test.toggle()" mdbWavesEffect>
    Toggle collapse
</button>

<div class="" [mdbCollapse]="isCollapsed" #test="bs-collapse">
    <p>Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident.</p>
</div>
        

Collapse events

Event Type Description
(showBsCollapse)="showBsCollapse()" This event fires immediately when the show instance method is called.
(shownBsCollapse)="shownBsCollapse()" This event is fired when a collapse element has been made visible to the user (will wait for CSS transitions to complete).
(hideBsCollapse)="hideBsCollapse()" This event is fired immediately when the hide method has been called.
(hiddenBsCollapse)="hiddenBsCollapse()" This event is fired when a collapse element has been hidden from the user (will wait for CSS transitions to complete).
                            
<button class="btn btn-primary waves-light" type="button" (click)="test.toggle()" mdbWavesEffect>
    Toggle collapse
</button>

<div class="" [mdbCollapse]="isCollapsed" #test="bs-collapse" (showBsCollapse)="showBsCollapse()" (shownBsCollapse)="shownBsCollapse()" (hideBsCollapse)="hideBsCollapse()" (hiddenBsCollapse)="hiddenBsCollapse()">
    <div class="card card-body">
        Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident.
    </div>
</div>
                            
                        
                            
import { Component } from '@angular/core';

@Component({
  selector: 'collapse-example',
  templateUrl: 'collapse-example.html',
})

export class CollapseExampleComponent  { 

    showBsCollapse() {}

    shownBsCollapse() {}

    hideBsCollapse() {}

    hiddenBsCollapse() {}
}            
                            
                        

Accessibility

Be sure to add aria-expanded to the control element. This attribute explicitly defines the current state of the collapsible element to screen readers and similar assistive technologies. If the collapsible element is closed by default, it should have a value of aria-expanded="false". If you’ve set the collapsible element to be open by default using the in class, set aria-expanded="true" on the control instead. The plugin will automatically toggle this attribute based on whether or not the collapsible element has been opened or closed.

Additionally, if your control element is targeting a single collapsible element – i.e. the data-target attribute is pointing to an id selector – you may add an additional aria-controls attribute to the control element, containing the id of the collapsible element. Modern screen readers and similar assistive technologies make use of this attribute to provide users with additional shortcuts to navigate directly to the collapsible element itself.


Accordion MDB Pro component

Extend the default collapse behavior to create an accordion.

Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS.
Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS.
Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS.

                            
<!--Accordion wrapper-->
<mdb-squeezebox [multiple]="false" aria-multiselectable="true">
    <mdb-item  *ngFor="let item of itemsList">
        <mdb-item-head> {{ item.title }} </mdb-item-head>
        <mdb-item-body> {{ item.description }} </mdb-item-body>
    </mdb-item>
</mdb-squeezebox>
<!--/.Accordion wrapper-->
                            
                        
                            
import { Component } from '@angular/core';

@Component({
  selector: 'accordion-example',
  templateUrl: 'accordion-example.html',
})

export class AccordionExampleComponent  {

    public itemsList:Object[] = [
        {
            title: 'Collapsible Group Item #1',
            description: 'Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven\'t heard of them accusamus labore sustainable VHS.'
        },
         {
            title: 'Collapsible Group Item #2',
            description: 'Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven\'t heard of them accusamus labore sustainable VHS.'
        },
         {
            title: 'Collapsible Group Item #3',
            description: 'Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven\'t heard of them accusamus labore sustainable VHS.'
        }
    ]

}