0

This is how you insert params into a directive.

<p [gridGroup]="gridGroup"></p>

But what I am wanting to do is make the param optional so that I won't have to always include it within my class.

I am required to insert gridGroup in each class that references this html source.

I have tried

<p [gridGroup?]="gridGroup"></p>

and

<p [gridGroup]="gridGroup?"></p>

Both give me compile errors

lealceldeiro
  • 14,342
  • 6
  • 49
  • 80
Demodave
  • 6,242
  • 6
  • 43
  • 58

2 Answers2

0

In your component intialize the gridGroup property to a value, that way if the property is not declared in the parent component it still has a value/won't cause errors.

SimplyComplexable
  • 1,116
  • 11
  • 19
0

You can do something like this

@Input set gridGroup(value: any) {
      this._gridGroup= value;
      doSomething(value);
    }
Mantu Nigam
  • 3,690
  • 7
  • 24
  • 41