Pass Boolean value in a component call from index.html

Issue

I have created a component and trying to pass boolean value inside it as @input which will help me to show/hide a div. But it is giving me undefined. can anyone please point out what is wrong in this?

Index.html

<abc-comp x="1" y="64" [showviewmore]="true"></abc-comp>

abc-comp.ts

  @Input() x = '';
  @Input() y = '';
  @Input() showviewmore : boolean;

abc-comp.html

  <div class="col-xs-4" *ngIf="showviewmore">
      //Some Content and tags
  </div>

Solution

try

<abc-comp x="1" y="64" showviewmore="true"></abc-comp>

Answered By – divya

Answer Checked By – David Goodson (AngularFixing Volunteer)

Leave a Reply

Your email address will not be published.