0


I have a component named center-info and another component named slideshow.
I inject to the center-info, html pages, that i stored in assets, with the help of the following code:

center-info.component.ts:

@Component({
  selector: 'app-center-info',
  templateUrl: './center-info.component.html',
  styleUrls: ['./center-info.component.css']
})
export class CenterInfoComponent implements OnInit {
  public centerId = "";
  constructor(private route: ActivatedRoute) { }

  ngOnInit(): void {
    this.route.paramMap.subscribe((params: ParamMap) => {
      let id = params.get('id');
      this.centerId = id;
    });
    $("#center-info").load(`assets/centers/${this.centerId}.html`);
  }
}

I can see the text I wrote in the html pages in assets, but when I try to call a component from one of the html pages in the asset, The component does not appear on the screen.
One of the html pages in assets:

<!DOCTYPE html>
<html>
<head>
  <link rel="stylesheet" href="assets/centers/centers.css">
</head>

<body>
  <div id="center-info">
    <p>this is html page in assets</p>

    <app-slideshow ></app-slideshow>

  </div>
</body>
</html>

How can I make the <app-slideshow ></app-slideshow> appear on the screen?
Thanks so much to all the helpers!

Mana
  • 63
  • 1
  • 9
  • Not a good idea to use JQuery in angular application: read this: [is-that-a-good-practice-to-use-jquery-with-angularjs](https://stackoverflow.com/questions/34707577/is-that-a-good-practice-to-use-jquery-with-angularjs) – HDJEMAI Jun 14 '20 at 00:52
  • Assets can use a url, so why not try an iframe with the src set to a url? – JWP Jun 14 '20 at 02:36
  • @JohnPeters, Thank you for your answer! But how can a component be represented in url? – Mana Jun 14 '20 at 06:34
  • Use a route. Routes tie URLs to components. Except for assets, they are statically always there. No Route route needed. – JWP Jun 14 '20 at 08:41

0 Answers0