jeudi 5 mai 2016

Pass div contents into ng-show angular function

I have this div:

<div class="col-md-3" ng-show="hideYN('hideme?')">hideme?</div>

And this Angular function in a controller (where $scope.test1 is bound to an input field):

$scope.hideYN = function(val) {
if (val.indexOf($scope.test1) == -1) {
  return false;
}
return true;

}

Basically, this is functioning as a searchable grid of divs, with divs being hidden whose content doesn't match the input value ($scope.test1).

However, I don't want to hard code the string parameter of the hideYN() function. Is there a way to pass the contents of the div to this function?




Aucun commentaire:

Enregistrer un commentaire