admin管理员组文章数量:1122846
I am questioning myself of whether or not to structure my Angular components in sub divs, to make the html better.
I do have a main page and a overview component. Is it good practices in Angular to move this component inside a div tag in the HTML file of the main page?
This is the main page HTML:
<div>
<app-overview />
</div>
This is the component HTML:
<div class="container">
<div class="headline">
<h2>...</h2>
<div class="form-button-container"></div>
</div>
<div class="objects">
...
<!-- objects -->
</div>
</div>
<!-- </div> -->
I was asking myself if the div component of the main page in Angular can be left out as well? Is this a worse solution?
I am questioning myself of whether or not to structure my Angular components in sub divs, to make the html better.
I do have a main page and a overview component. Is it good practices in Angular to move this component inside a div tag in the HTML file of the main page?
This is the main page HTML:
<div>
<app-overview />
</div>
This is the component HTML:
<div class="container">
<div class="headline">
<h2>...</h2>
<div class="form-button-container"></div>
</div>
<div class="objects">
...
<!-- objects -->
</div>
</div>
<!-- </div> -->
I was asking myself if the div component of the main page in Angular can be left out as well? Is this a worse solution?
Share Improve this question edited Nov 22, 2024 at 0:14 Naren Murali 54.6k5 gold badges40 silver badges70 bronze badges asked Nov 21, 2024 at 11:41 thegreylukthegreyluk 114 bronze badges1 Answer
Reset to default 1There is no best practices for such things, you can just create your component using ng g c --display-block
and it will be the same as the div
element, so it can be the wrapper of the contents.
If you want to transform your existing component, then use the :host
selector, to make it display: block
.
@Component({
...
styles: [`:host: display: block`]
...
})
export class SomeComponent {
...
Related Answer - Angular component default style css display block
本文标签: htmlAngular Components Structure in DivsStack Overflow
版权声明:本文标题:html - Angular Components Structure in Divs - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736311268a1934677.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论