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 badges2 Answers
Reset to default 2Just 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条)