admin管理员组文章数量:1415644
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>
.
本文标签: javascriptLoading External URL in Angular2 routeroutletStack Overflow
版权声明:本文标题:javascript - Loading External URL in Angular2 router-outlet - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745240575a2649303.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论