Angular filter html

2

I have an ng-repeat that returns me a list.

Every line, I have a default text that appears if a variable is > 0

So far so good.

How do I add in the filter only show the record when the default text is filled in?

The content is in a div:

<div name="pesq" id "pesq" style="padding-left: 5px;color:red"> =texto padrão= </div>


<tr ng-repeat="nome in nomes | filter: 'pesq'">
    
asked by anonymous 05.02.2018 / 12:44

2 answers

3

You can do:

<tr ng-repeat="[objecto] in [colecção] | filter: {[propriedade]: '[texto]'}">

Where propriedade is the property name of the object you want to use to filter, and texto is the text you want to find in the property.

That is, (assuming the property name is pesq and the text is padrao ):

<tr ng-repeat="nome in nomes | filter: {pesq: 'padrao'}">

All nome objects that contain the pesq property with the text padrao will be written to the DOM.

    
05.02.2018 / 12:59
0

Dude, one option would be to do this just with css and jquery. You can leave the text hidden with display:none or leave it invisible with visibility:hidden , then in its condition, you would just capture the element with jquery and add the css. Example $('#elemento').css("display","block"); or $('#elemento').css("visibility",visible"); If you have any questions, please comment on: D

$('#inp').focusout(function(){
   if($(this).val().length >0)
   {
     $('#texto').css('display','block')
   }
   else{
     alert('tamanho menor que 0')
     $('#texto').css('display','none')
   }

})
#texto{
  display: none;
}
<p id='texto' > texto exibido </p>

<input type="text" id="inp"/>
<script src="https://code.jquery.com/jquery-3.3.1.min.js"> </script>
    
05.02.2018 / 12:57