Can't bind since it isn't a known property of angular component

2486 views css
6

I am trying to conditionally set a classname based on a boolean variable. I have set the variable within the parent component:

  public alteredSidebar: boolean;

And this is my though process behind conditionally defining which class it is:

  <div [class]="alteredSidebar == false ? 'secondsidenav' : 'sidenav'" id="rollup-sidenav" [ngClass]="{ 'greyout': greyOut }"></div>

Here is an instance of where I am using it and I am expecting the class to be set to 'secondsidenav':

<app-rollup [data]="rollupData" (resetCalled)="onRollupReset()" (entrySelected)="onRollupSelectEvent($event)" [alteredSidebar]="false">
            </app-rollup> 

However I am getting the following error: "Can't bind to 'alteredSidebar' since it isn't a known property of 'app-rollup'."

answered question

1 Answer

12

use @Input() decorator on it

@Input()
public alteredSidebar: boolean;

posted this

Have an answer?

JD

Please login first before posting an answer.