Welcome StackOverflow!
I am having problems with my code. As you can see, I want to be able to call a line with a set width (bootstrap format), since I do not want to enter a class every time.
So, I thought about the following:
import { Component, Input } from '@angular/core'; @Component({ moduleId: module.id, selector: 'content', template: ` <div class="row"> <div [ngClass]="contentClass" id="content" [ngStyle]="{ 'color': 'black', 'font-size': '20px' }"> <ng-content></ng-content> </div> </div>`, styleUrls: ['content.stylesheet.css'] }) export class ContentComponent { @Input() rowWidth = "12"; contentClass=(("col-lg-" + this.rowWidth)+(" col-sm-" + this.rowWidth)+(" col-xs-" + this.rowWidth)); }
But as soon as I call the component from another component, it does not work the way I want.
<banner bannerHeight="300px"></banner> <content rowWidth="6"></content>
If I used, for example,
<content [ngStyle]="{'color': 'black'}"></content>
The operation completes successfully. Directives and imports are set correctly in the parent component.
So here is my question: how do I get it to work the way I want it?
source share