我当前面临的问题是a标记生成的链接链接到基础页面。如您在图片中所见,它链接到
localhost:3000#hello
我的目标是使其链接到
localhost:3000 / bodyText#hello
标签将来自外部来源,因此我的测试示例对此进行了模仿。到目前为止,我一直在使用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() {
}
}