javascript - Loading External URL in Angular2 router-outlet - Stack Overflow

I am developing an application using Angular2.I have a ponent with the following template:<div>&

I am developing an application using Angular2. I have a ponent with the following template:

<div>
  <router-outlet></router-outlet>
</div>

Can someone please help me how to load an external URL 'www.example' in this div?

I am developing an application using Angular2. I have a ponent with the following template:

<div>
  <router-outlet></router-outlet>
</div>

Can someone please help me how to load an external URL 'www.example.' in this div?

Share Improve this question asked Aug 9, 2016 at 23:29 UnderWoodUnderWood 8813 gold badges14 silver badges23 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 2

Just create a ponent to render inside <ng-outlet> by using the routing config. Then you ponent template inside should have an <iframe> pointing to your external site.

import {Component, OnInit} from '@angular/core';

@Component({
    selector: 'app-external-page',
    templateUrl: './external-page.ponent.html',
    styleUrls: ['./external-page.ponent.css']
})

export class ExternalPageComponent implements OnInit {

    title = 'app works!';

    constructor(private _stellarService: StellarService) {
    }

    ngOnInit(): void {
    }

}

Then your ponent template should look like

<div>
    <iframe src="yourexternalpage url"></iframe>
</div>

Having a code like the one above, only remaining step if to configure a route in your routing.

did you get answer for this ?

You can have a ponent as mentioned here . Import and add it to your NgModule; After that import it in the page you want and use the selector instead of <router-outlet>.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745240575a4618157.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信