6

Is it possible to launch angular2 cli 4.0 into an iframe on a website, in order to have a preview of angular2 components? I would be grateful for an answer to this question.

wscourge
  • 10,657
  • 14
  • 59
  • 80
Adrian Sawicki
  • 590
  • 5
  • 22

2 Answers2

5

You could run an angular app and load it into iframe. In your app, you should create a route where only one component will be visible. Then you can load it into iframe in the other website.

Example: your component would be available at http://localhost:4200/components/card

and then on your website, you can load it like this: <iframe src="http://localhost:4200/components/card></iframe>

Mattonit
  • 601
  • 7
  • 22
1

Lets say you angular app is hosted at http://localhost:4200 which is the default url when you run the app with ng serve

Just add <iframe src='http://localhost:4200'> in you web app and angular app will be loaded inside you website.

Master Yoda
  • 531
  • 8
  • 22