How to implement ng-show in a self-complete angularjs

0

Hello everyone I have this autocomplete of material and I want to get that when selecting an item my label <p> is displayed:

<div class="resumen" ng-cloak>     
    <md-autocomplete    
            md-selected-item="selectedItem"   
            md-selected-text="selectedItem"   
            md-search-text="searchText"  
            md-items="item in querySearch(searchText)"  
            md-item-text="item.rut"  
            placeholder="Ingrese rut del paciente">  
        <md-not-found>Rut no encontrado.</md-not-found>  
        <md-icon md-svg-icon="images/buscame.svg"></md-icon>    

        <span md-highlight-text="searchText">{{item.rut + ' Numero: '+item.numero}}</span>   
    </md-autocomplete>     

    <p style="padding-top:20px; font-size:18px;" ng-show="  {{!selectedItem.rut === undefined}}">
        {{'El rut seleciado es: ' +selectedItem.rut+' y su numero de atención: ' + selectedItem.numero}}
    </p>

</div>

How can I correctly implement in this situation a ng-hide , ng-show until I think of a ng-change but I earn it ... regards ...

    
asked by Hernan Humaña 01.11.2016 в 16:03
source

1 answer

1

This expression

ng-show="{{!selectedItem.rut === undefined}}"

It should be

ng-show="!!selectedItem.rut"

or

ng-show="selectedItem.rut"

This directive is designed to use an expression, not an interpolation {{}} as you currently have it.

Also, it is not necessary to compare against undefined , you can use truthy and simplify the expression using !! to coerce to boolean or use the value directly since if it has something the expression will evaluate to true . Remember that what you want is to show the value if there is something there.

    
answered by 01.11.2016 / 16:26
source