Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

96
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda