Angular and jQuery: Load component dynamically

302 Views Asked by At

I'm using the jquery-confirm plugin with Angular 6, and I can open alerts and dialogs with static content:

<button (click)="openConfirm()">Open Confirm</button>

openConfirm() {
  $.confirm({
    title: 'Test',
    content: 'It works!'
  });
}

Now I want to load a component inside, and I thought if I pass the selector in a string I would load it. But it didn't.

I think the plugin uses the jquery html() function to add html to the confirm box. Because when I tried this:

$.confirm({
  title: 'Test',
  content: '<app-confirm></app-confirm>'
});

I checked and the plugin actually added the selectors to the html, but it didn't load the component.

0

There are 0 best solutions below