【发布时间】:2016-07-05 02:43:31
【问题描述】:
我是 Angular 的新手。我从版本开始。 2.
我需要链接到file://... URL。
我试过正常的href:
注意:app 是处理应用程序的网络模型对象。
<a target="_blank" href="file://{{app.outputPath}}/index.html">no link here</a>.
这不起作用 - 链接在那里,具有正确的 URL,但 Angular 似乎以某种方式阻止了该事件。为什么?
所以我见过ng-href,但那是针对 Angular 1.x 的。据我所知,there's no *ngHref。所以这只是一个幼稚的尝试:
<a target="_blank" *ngHref="file://{{app.outputPath}}/index.html">over a directive</a>.
我还看到了一些关于路由的东西,但它似乎只适用于应用程序中的内部链接:
<a [router-link]="['/staticReport', {path: app.outputPath}]">see the report</a>.
app.component.ts:
@RouteConfig([
...
{path:"/staticReport/:path", redirectTo: 'file:// ???? ' }
])
创建外部链接的方法是什么?
【问题讨论】:
-
您是否检查过在 DOM 中生成的 URL 是什么样子的? (“检查元素”链接上的上下文菜单)。实际上,“
app是处理应用程序的网络模型对象”并没有提供太多信息。
标签: hyperlink angular external angular2-routing angular2-directives