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

156
Visualizações
Reassign Variable which is coming as @Input in component

I have a component which takes a boolean value as @Input. I am controlling a div using ngIf with this value(to show/hide). Now, when I pass value true or false in both cases, the UI shows the div, whereas when not giving anything, it does not. Am I missing something here?

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>

Also, I am trying to reassign the value of showviewmore variable in the ngOnInit() method but it never enters the if statement

  ngOnInit(): void {
   if(!this.showviewmore){
     this.showviewmore = newValue;
   }

Can anyone please help me? Thanks in advance

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

showviewmore="true" passes the value as string. You have to modify [showviewmore]="true"

<abc-comp x="1" y="64" [showviewmore]="true"></abc-comp>
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