我正在尝试将路由器出口放置的元素设置为有角度,并且要确保生成的元素的宽度为100%
从大多数回复中,我看到我应该使用::ng-deep选择器,但是从Angular的文档中它被弃用了.有替代品::ng-deep吗?
我对Angular很新,来自React.js背景.
我做了一个简单的网格组件,如下所示:
grid.component.js
import { Component, OnInit, Input } from '@angular/core';
@Component({
selector: 'app-grid',
template: `
<div [ngStyle]="styles()" [ngClass]="passClass">
<ng-content></ng-content>
</div>
`,
styles: [`
div {
display: flex;
}
`]
})
export class GridComponent implements OnInit {
@Input() direction: string;
@Input() justify: string;
@Input() align: string;
@Input() width: string;
@Input() passClass: string;
constructor() { }
ngOnInit() {
}
styles() {
return {
'flex-direction': this.direction || 'row',
'justify-content': this.justify || 'flex-start',
'align-items': this.align || 'flex-start',
...(this.width && { width: this.width }) …Run Code Online (Sandbox Code Playgroud)