Я довольно новичок в 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 })
};
}
}
И я хочу использовать его в других компонентах, как показано ниже: aboutus.component.html
<app-grid passClass="about-us page-container">
<app-grid direction="column" passClass="left">
<div class="title blue bold">
An open community For Everyone
</div>
<div class="large-desc grey">
This conference is brought to you by
the Go Language Community in
India together with the Emerging
Technology Trust (ETT). ETT is a non-
profit organization, established to
organize and conduct technology
conferences in India. It’s current
portfolio includes
</div>
</app-grid>
</app-grid>
aboutus.component.sass
.about-us
position: relative
.left
width: 50%
&:after
bottom: 0
right: 0
z-index: 0
margin-right: -5vw
position: absolute
content: url(../../assets/images/footer.svg)
Но что произойдет, если CSS, связанный со вторым компонентом, не будет работать?
Я немного знаю об изоляции CSS, но не смог понять,здесь это влияет.
PS: Пожалуйста, не стесняйтесь оставлять отзывы и за пределами этого вопроса.