Questions tagged «ng-content»

4
多种ng含量
我正在尝试使用ng-contentAngular 6中的多个组件来构建自定义组件,但这不起作用,我也不知道为什么。 这是我的组件代码: <div class="header-css-class"> <ng-content select="#header"></ng-content> </div> <div class="body-css-class"> <ng-content select="#body"></ng-content> </div> 我试图在另一个地方使用此组件,并在body和的标头select中呈现两个不同的HTML代码ng-content,如下所示: <div #header>This should be rendered in header selection of ng-content</div> <div #body>This should be rendered in body selection of ng-content</div> 但是组件使空白。 你们知道我可能做错了什么,还是在同一组件中呈现两个不同部分的最佳方法是什么? 谢谢!
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.