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

325
Views
Angular ngModelChange parameter function different to $event
I want to send a different parameter to the $event in the function:


 <div class='col-sm'>
      <label class="col-3 col-form-label">Origen</label>
          <div class="col-4">
              <select [(ngModel)]="dana" class="form-control"  
                 (ngModelChange)="filterFor($event)"required>
                   <option *ngFor="let dano of danos" 
                       [value]="dano.comment">{{dano.make}}
                   </option>
             </select>
          </div>
     </div>

I would like to send the parameter in the function filterFor call:

    <div class='col-sm'>
         <label class="col-3 col-form-label">Origen</label>
             <div class="col-4">
                 <select [(ngModel)]="dana" class="form-control"  
                     (ngModelChange)="filterFor(dano.tipo)"required>
                   <option *ngFor="let dano of danos" 
                        [value]="dano.comment">{{dano.make}}
                   </option>
                 </select>
             </div>
       </div>

Fails:

error TS2551: Property 'dano' does not exist on type 'ComunidadFiltracionesComponent'. Did you mean 'danos'? .

Do you know the format of the parameter so that it accepts it? Thanks in advance

Expand the query:

I have an object with different parameters:

let car = [ {'make': 'Ford', 'comment': 'The vehicle has a heavy internal combustion engine....'}];

In dropdown (ngFor), when the customer selects the make of the car, we take the comment variable.

If I want to compare vehicles:

if (dana == 'The vehicle has a heavy internal combustion engine....'){
this.quality = 'goog';
}

To find out which brand the client has entered, I have to compare through the comment (too long). I want to compare by the brand variable:

if (dana == 'Ford'){
this.quality = 'goog';
}

See in stackblitz : https://angular-ivy-mu5mrh.stackblitz.io/

about 4 years ago · Santiago Trujillo
2 answers
Answer question

0

if you use (ngModelChange)="filterFor($event)" in your function filterFor you received the [value] of the option selected.

if you use as value [value]="dano.make"

You can use some like

filterFor(value:any){
   this.data=value; //<--if not use [(ngModel)] else [ngModel]
                    //don't forget equal the variable to value

   const dano=this.datos.find(x=>x.make==value)
   console.log(dano) //<--here you has the whole object
   //you can, e.g.
   if (value=='Ford')....
   //or
   if (dano.comment=='The vehicle has a heavy internal..')...
}
about 4 years ago · Santiago Trujillo Report

0

the issue in your code is that your'e trying to access dano variable which is out of the loop scope and hence isn't being recognized

about 4 years ago · Santiago Trujillo 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!