Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

125
Visualizações
Ng If con un booleano - para cambiar el título de una página

En mi página Stock tengo varios campos con un título llamado Title 1 .

ingrese la descripción de la imagen aquí

¡Si hago un console.log estoy en mi primera página!

 ngOnInit() { this.currentPortfolio = this.shrd.getData('currentPortfolio'); this.subPage = 'stocks'; this.sectionTitle = ""; this.pageTitle = "Options"; for (var i = 0; i < this.optionsDropdownFilters.length; i++) { this.issuers.actionsGrouped[this.optionsDropdownFilters[i]] = []; } console.log("First page => Tile 1 : " + JSON.stringify(this.subPage = 'stocks')); this.initiate(); }

En Google Chrome tengo esto: ingrese la descripción de la imagen aquí

Ahora, hago clic en el botón Search en mi página Stock ... Quiero cambiar Title1 a Title2 .

ingrese la descripción de la imagen aquí

Si hago un console.log, estoy en mi segunda página

ingrese la descripción de la imagen aquí

 launchSearchSelected(t) { this.searched = true; this.dateNotValid = false; this.dateDoesntExist = false; if (this.search.equityDate.length == 0) { this.dateDoesntExist = true } if (t == 'A' && this.search.equityOptionCode > 0 && this.search.equityDate.length > 0) { this.launchSearchResult(t, this.search.equityOptionCode, this.search.equityDate); } else if (t == 'I' && this.search.indexOptionCode.length > 0 && this.search.indexDate.length > 0) { this.launchSearchResult(t, this.search.indexOptionCode, this.search.indexDate); } console.log("Second Page => Title 2 " + JSON.stringify(this.searched = true)); }

En mi HTML, no entiendo cómo puedo cambiar de un título a otro con el booleano.

 <ng-container *ngIf="subPage === 'stocks' "> <div class="breadcrumb d-flex justify-content-between"> <h1>Title 1 </h1> </div> </ng-container>
about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

Es difícil saber cuál es la mejor manera de proceder sin más información, pero si solo desea cambiar el título en función de la variable this.subPage que tenga el valor " stocks " o no (como parece que lo está intentando), entonces puede hacer esto:

 <ng-container> <div class="breadcrumb d-flex justify-content-between"> <h1 *ngIf="subPage == 'stocks'">Title 1</h1> <h1 *ngIf="subPage != 'stocks'">Title 2</h1> </div> </ng-container>
about 4 years ago · Juan Pablo Isaza Relatório

0

tengo la solución:

 <ng-container *ngIf="subPage === 'stocks' "> <ng-container *ngIf="spinners.search === true "> <div class="breadcrumb d-flex justify-content-between"> <h1>Title 1 </h1> </div> </ng-container> </ng-container> <ng-container *ngIf="subPage === 'stocks' "> <ng-container *ngIf="spinners.search === false "> <div class="breadcrumb d-flex justify-content-between"> <h1>Title 2 </h1> <button (click)="goBack()" class="btn btn-primary"> Back </button> </div> </ng-container> </ng-container>
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda