是否可以使用隐形组件容器?我尝试了选择器:'[app-root]’已经包含以下标签,但它们都创建了一个dom元素:
<template>,<ng-template>,<ng-container>
如果确实需要这个容器,那么如果Angular只呈现HTML注释会很棒.
... @Component({ selector: '[your-component]' }) ...
这样,your-component就是一个属性,您可以这样使用:
<div your-component>Some content...</div>
在这种情况下,您可以保证样式不会破坏.
附:据我所知,这个特性(在Angular 1中替换)在Angular 1中被弃用了,所以它不是你对Angular 2的期望.