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

102
Visualizações
Is this bad practice for AngularJS

I wish to place:

{{$ctrl.agrmtDetails.form.$invalid == true? $ctrl.checkValidation() : $ctrl.checkValidation()}} 

I currently have:

<p style="display:none" >{{$ctrl.agrmtDetails.form.$invalid == true?$ctrl.formData.agrmtDetails.validated = false : $ctrl.formData.agrmtDetails.validated = true}}</p>

Both lines will be on the HTML page.

I just need something to appear if a condition is met.

Are both okay? I just thought having a p-tag and hiding it seems silly.

Thanks.

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

0

Yes, I would consider both of those to be bad practice. It sounds like you are really looking for a scope watcher: https://docs.angularjs.org/api/ng/type/$rootScope.Scope#$watch

Here is an example of what you could put into your controller:

$scope.$watch(function() {
    return this.agrmtDetails.form.$invalid == true; // Value that is being "watched"
}, function(newValue) {
    this.formData.agrmtDetails.validated = !newValue;
    // Or whatever "checkValidation()" was intended to be.
});
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