Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

361
Views
*ngIf para atributo html en Angular2
<ion-navbar hideBackButton > <ion-title> </ion-title> ... ...

Quiero que hideBackButton esté allí de forma condicional y no quiero repetir todo el elemento ion-navbar con *ngIf. ¿Es posible aplicar * ngIf para el atributo hideBackButton?

over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

Debe proporcionar valores null a booleanos para que se eliminen,

 <ion-navbar [attr.hideBackButton]="someExpression ? true : null">

de lo contrario angular crea

 <ion-navbar hideBackButton="false">
over 4 years ago · Santiago Trujillo Report

0

Puede aprovechar la interpolación:

 <ion-navbar [attr.hideBackButton]="someExpression"> <ion-title> </ion-title> ... ...

Si someExpression es nulo, el atributo no estará presente y si someExpression es una cadena vacía, el atributo estará allí. Aquí hay una muestra:

 @Component({ selector: 'my-app', template: ` <div [attr.hideBackButton]="someExpression"> Test </div> <div (click)="toggleAttribute()">Toggle</div> ` }) export class AppComponent { constructor() { this.someExpression = null; } toggleAttribute() { if (this.someExpression==null) { this.someExpression = ''; } else { this.someExpression = null; } } }

Vea este plunkr: https://plnkr.co/edit/LL012UVBZ421iPX4H59p?p=preview

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!