Kadircan İşbilen
Kadircan İşbilen

Reputation: 1

How do I hide a title without hiding the content by using *ngIf?

Can I hide this title without hiding content? When I set "IsTitleDisabled" true, the content is hiding. I want to hide only "Title.PhoneInfo". Is there a way to do it?

<form-layout-content title="{{'Title.PhoneInfo'}}" *ngIf="!IsTitleDisabled">
<!-- content -->
</form-layout-content>

Upvotes: 0

Views: 230

Answers (2)

Kadircan İşbilen
Kadircan İşbilen

Reputation: 1

I figured it out by using a method which is name is getContentTitle() from .ts side. Thanks for helping.

    getContentTitle(): string {
return !this.IsTitleDisabled ? this._phoneInfoTitle : this.emptyString;
}

HTML side :

<form-layout-content title="{{getContentTitle()}}">
<!-- content -->
</form-layout-content>

Upvotes: 0

Ganesh
Ganesh

Reputation: 6016

We can bind title based on your boolean check IsTitleDisabled to avoid it for entire content.

Do some changes like below,

<form-layout-content [attr.title]="!IsTitleDisabled ? {{'Title.PhoneInfo'}} : ''">
    <!-- content -->
</form-layout-content>

If not this 'Title.PhoneInfo' specific like constants simply we can avoid {{ }}:

  <form-layout-content [attr.title]="!IsTitleDisabled ? Title.PhoneInfo : ''">
        <!-- content -->
  </form-layout-content>

Upvotes: 1

Related Questions