ng-checked checkbox

0

I have the following code:

<input
    type="checkbox" ng-checked="false"
    ng-model="query"
    ng-checked="loadValues(column.field)" />    

Every time I give the checkbox, it calls the method, but I just want it to call when it is checked = true

    
asked by sirdaiz 13.06.2017 в 16:26
source

1 answer

1

You could do it in the ng-change instead of using the check:

ng-change="((query)?loadValues(column.field):'')"

You could also verify in the function inside the controller, if the value is true and you continue with the execution:

loadValues(value){
  if(query){
    // do something
  }
}

I leave you a working plunker with the first example: link

I hope that is what you are looking for, otherwise, do not hesitate to ask again. Greetings

    
answered by 13.06.2017 / 16:36
source