该页面显示基本标记,舒适消息和加载指示 .
<html>
...
<body app>
...page layout and loading stuff...
</body>
</html>
而根组件是
@Component({
selector: 'body[app]',
template: `<ng-content></ng-content>`
})
App {}
一个证明问题的 Sleuth 是here .
在SPA初始化之后,它应该在保存现有基本布局的同时引导 body
元素并编译组件 .
但是,根组件只是忽略 ng-content
.
这导致两种选择 . 初始布局应该被转储并仅在引导之后显示 . 或者它应该在根组件模板和HTML文档中重复(可能与服务器端模板) . 他们都不够好看 .
body
包含敏感标记,无法将其包装到子组件中以克服此限制 . 我打算使用Angular Universal为SPA提供整洁的静态预览,但不是在这个阶段 .
看起来这是一个已知的问题,但我找不到一个可行的解决方案 .
怎么修好?
2 回答
以下链接的状态为
fixed by ivy
. 常 Spring 藤是角度v7.0的里程碑 .根元素不支持Transcludes,你可以_t94812_t部分角度 . 如果你能够't embed the html within another component then I wouldn' t期望它也可以与
ng-content
一起使用 .从https://github.com/angular/angular/issues/1858#issuecomment-207993202
计划在根组件中使用
<ng-content>
来实现 .https://github.com/angular/angular/issues/4946