Base solution for your next web application
Starts in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

Collapse component causes error #4967


User avatar
0
TimMackey created

I attempted to implement the "Manual toggle" example at.. [https://ngx-bootstrap-latest.surge.sh/#/collapse#manual-toggle])

Chrome and Edge browses report: ERROR Error: Uncaught (in promise): Error: Template parse errors: There is no directive with "exportAs" set to "bs-collapse" (" </button> <hr> <div [ERROR ->]#collapse="bs-collapse" [collapse]="isOpen" class="card card-block card-header"> "): ng:///MainModule/TtmDashboardComponent.html@167:21 Can't bind to 'collapse' since it isn't a known property of 'div'. ...


5 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    Can you share in which modules have you imported CollapseModule ? I think you should import CollapseModule into the module you are using it.

    You also need to import it into app.module like below;

    CollapseModule.forRoot()
    
  • User Avatar
    0
    TimMackey created

    main-routing.module.ts

    ... // (additional imports)
    import { NgModule } from '@angular/core';
    import { CollapseModule } from 'ngx-bootstrap';
    
    @NgModule({
        imports: [
            CollapseModule.forRoot(),
    ...
    

    dashboard.component.html

    ...
        <button type="button" class="btn btn-primary"
                (click)="collapse.show()">Show content
        </button>
        <button type="button" class="btn btn-primary"
                (click)="collapse.hide()">Hide content
        </button>
        <hr>
        <div #collapse="bs-collapse" [collapse]="isOpen"
             class="card card-block card-header">
          <div class="well well-lg">Some content</div>
        </div>
    ...
    

    dashboard.component.ts

    import { Component, AfterViewInit, Injector, ViewEncapsulation, ElementRef, ViewChild } from '@angular/core';
    import { CollapseModule } from 'ngx-bootstrap';
    ...
    export class TtmDashboardComponent extends AppComponentBase implements AfterViewInit {
    ...
        isOpen = false;
    
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @TimMackey,

    Instead of main-routing.module.ts, can you include CollapseModule into main.module like below ?

    imports: [
            CollapseModule,
            ....
    ]
    

    Then, include it into app.module like below;

    imports: [
            CollapseModule.forRoot(),
            ....
    ]
    
  • User Avatar
    0
    TimMackey created

    Your solution worked. Thank you!

  • User Avatar
    0
    ismcagdas created
    Support Team

    Great :)