Is it possible to conceal dom elements within an ng-template?

Utilizing ng-bootstrap, I am creating a Popover with HTML and bindings. However, the ng-template keeps getting recreated every time I click the button, causing a delay in the initialization of my component. Is there a way to hide the ng-template instead?

Note: English is not my native language, so please forgive any confusion.

I have attempted using ng-container, but ngbPopover seems to only accept ng-template.

<button type="button" class="card tools-toc btn btn-outline-primary"
    #popover="ngbPopover" [ngbPopover]="popLegend" [ngClass]="{'active': popover.isOpen()}"
    placement="top" [autoClose]="false" popoverClass="popover-legend" (click)="toggleToc()">
    <i class="fas fa-layer-group"></i>
  </button>

<ng-template #popLegend>
  <div>
    <div class="legend-title">Data Layers</div>
    <div >
      <app-core-toc [config]="_configService[1]" [omElec]="true">
      </app-core-toc>
      <app-core-toc [config]="_configService[0]" [omWork]="true">
      </app-core-toc>
    </div>
  </div>
</ng-template>

My goal is to initialize app-core-toc on load and then simply hide or show the template when the button is clicked.

Answer №1

Investigate the ng-bootstrap source code - currently, in version 5.1.0, it consistently generates an embedded view. This behavior may be subject to change down the line. If you have suggestions for enhancing this functionality, don't hesitate to share them on https://github.com/ng-bootstrap/ng-bootstrap/issues

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Scroll horizontally in Ionic 3 without displaying the scrollbar by implementing a button

Is there a way to implement ion scroll in such a manner that upon clicking the right arrow button, it smoothly transitions to the next element within the div section of ion content in Ionic 3 without displaying any scrollbar? I want the scrollbar to remain ...

Exploring the Connection with JSON-server

While creating a simulated API using json-server, I encountered an issue with passing a query. When utilizing _expand, I am able to display the parameters of a relationship, but it doesn't seem to work when the relationship is nested within a child. ...

What is the purpose of the .default() method being added to the class constructor in transpiled Typescript code

In TypeScript, I have the following code snippet to create an instance of ConnectRoles Middleware in Express: let user = new ConnectRoles(config); The middleware initialization is expected to be a simple call to a constructor. However, after transpiling, ...

Issue encountered during mozjpeg installation - unable to locate mozjpeg's cjpeg in the vendor directory due to

During my attempt to set up mozjpeg within a Docker container running NAME="Alpine Linux" ID=alpine VERSION_ID=3.11.7 PRETTY_NAME="Alpine Linux v3.11" HOME_URL="https://alpinelinux.org/" BUG_REPORT_URL="https://bugs.alpin ...

Encountering issues with redirecting the URI when using Oidc-client in an Angular2 application with hash

I am currently following a tutorial on Authenticating Angular2 with Oidc-client and attempting to incorporate the authentication aspect into my project. Since Angular2 is using { provide: LocationStrategy, useClass: HashLocationStrategy } my URLs are no ...

Issues with the execution of Typescript decorator method

Currently, I'm enrolled in the Mosh TypeScript course and came across a problem while working on the code. I noticed that the code worked perfectly in Mosh's video tutorial but when I tried it on my own PC and in an online playground, it didn&apo ...

What are the steps to expand the express object with TypeScript?

I am facing an issue where, after compiling a typescript project, the express import import {Request, Response} is not showing up. I am now attempting to use require, but I am unsure of how to extend the express object and utilize req and res. Any assistan ...

Issues related to .maps and the use of import 'rxjs/add/operator/map';

Having an issue with Angular 4 and rxjs/add/operator/map. Even after importing rxjs/add/operator/map, I am unable to use .map. Visual Basics keeps displaying two error messages: message: 'Declaration or statement expected.' message: 'Cannot ...

Passing headers using a universal method in HTTP CRUD process

My service function is structured like this: Please note: I am required to work with cookies book(data: Spa): Observable<any> { return this.http.post(`${environment.apiURL}:${environment.port}/${environment.domain}/abc/my.json`, data, { ...

How can I customize a Vue component slot in Storybook 8.0.6 using Vue 3.4 and Typescript to display various subcomponents within a story?

Incorporating a variety of sub-components into my Vue 3 component based on context is proving to be a challenge. Utilizing slots seems to be the solution in Vue 3, but I'm struggling to make it work within Storybook 8, which I'm using to showcase ...

Displaying data from an Angular subscription in a user interface form

I am attempting to transfer these item details to a form, but I keep encountering undefined values for this.itemDetails.item1Qty, etc. My goal is to display them in the Form UI. this.wareHouseGroup = this.formBuilder.group({ id: this.formBuilder.contr ...

Challenge encountered when utilizing angular 2 RC router for programmatic route navigation

Currently, I am utilizing the RC router in version rc1 with two defined routes as shown below: @Routes([ {path: '/', component: HomeComponent}, {path: '/signin', component: SigninComponent}, {path: '/dashboard', c ...

Issue with Material Sort functionality when null objects are present

I've encountered an issue with my code. I created a feature that adds empty rows if there are less than 5 rows, but now the sort function is no longer functioning properly. Strangely, when I remove the for loop responsible for adding empty rows, the s ...

Leveraging property information for a dropdown field

In my index.tsx file, I am fetching data that I pass to the component FormOne. This allows me to access the data in FormOne using props.data const [data, setData] = useState([]); ... return ( ... <FormOne data={data} /> ); I am looking to ...

Using Angular to assign a CSS variable to the before/after pseudo-classes

Having trouble passing a variable with [ngStyle] and reading it on the ::before class, any guidance in the right direction would be much appreciated! CSS: .handle-slider__control { height: 7px; z-index:1; background: $colour-alto; positi ...

Using axiosjs to send FormData from a Node.js environment

I am facing an issue with making the post request correctly using Flightaware's API, which requires form data. Since Node does not support form data, I decided to import form-data from this link. Here is how my code looks like with axios. import { Fl ...

Error with dateAdapter targeting a particular language

Currently facing an issue with the Angular material date picker when using a specific language - ka. Here is an example of the problem: constructor( private dateAdapter: DateAdapter<Date>, public noticesService:NoticesService, public d ...

Pressing the confirm button will close the sweet alert dialog

When pressing the confirm button, the swal closes. Is this the intended behavior? If so, how can I incorporate the loading example from the examples? Here is my swal code: <swal #saveSwal title="Are you sure?" text ="Do you want to save changes" cancel ...

Making if-else statements easier

Greetings! I have a JSON data that looks like this: { "details": { "data1": { "monthToDate":1000, "firstLastMonth":"December", "firstLa ...

Angular page startup triggers NPM, leading to a sudden crash

Our ASP.Net + Angular web pages running on the IIS server (built with .Net Core 2.1 and Angular5) have suddenly stopped functioning. An error message "AggregateException: One or more errors occurred. (One or more errors occurred. (The NPM script 'sta ...