【发布时间】:2018-10-03 07:14:45
【问题描述】:
我目前面临的问题是 a 标签生成的链接链接到基本页面。正如您在图片中看到的那样,它链接到
localhost:3000#hello
我的目标是让它链接到
localhost:3000/bodyText#hello
a 标记将来自外部来源,因此我的测试示例模仿了这一点。到目前为止,我一直在使用 innerHTML 指令将外部 html 放入 html 模板中。
这是我正在使用的组件
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-test',
template: '<div [innerHTML]=html></div>',
styleUrls: ['./test.component.css']
})
export class TestComponent implements OnInit {
constructor() {
}
html = "<a href=\"#hello\" title=\"hello\">A tag </a> <a name=\"hello\" id= \"hello\"/> "
ngOnInit() {
}
}
【问题讨论】:
-
你如何设置
base-href?你能证明吗 -
在 index.html 中我有
如果你指的是这个