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)
-
0
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()
-
0
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;
-
0
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(), .... ]
-
0
Your solution worked. Thank you!
-
0
Great :)