lundi 23 février 2015

Angular custom function, if(value == value) is treated as value LIKE value

I'm pretty new to angular so please be gentle.


the problem:


i have a custom filter for a dropdown using ng-repeat on the options



<select ng-model="SelectPart">
<option ng-repeat="part in parts| filter:customFunction" value="{{ part.id }}">{{ part.name }}</option>
</select>


here is the custom function:



$scope.customFunction = function(item){
if (item.parent_part_id == 2) {
return true;
}else if(item.id == 2){
return true;
};
return false;
};


now here is my question:


Why does the function return true when the part.id is 12?

how come that when i say == in an if, it acts more as if it were a LIKE statement in mysql?

what can i do to fix this?


Aucun commentaire:

Enregistrer un commentaire