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

94
Views
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 answers
Answer question

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 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!