Join the Stack Overflow Community
Stack Overflow is a community of 4.7 million programmers, just like you, helping each other.
Join them; it only takes a minute:
Sign up

I have to made something like this plunker I found, an autocomplete, but I have to use a php array, using $http.

If I put an alert to see my array, works fine, but I don't have any idea of what I have to do to make this filter in angularjs :(

My $http:

/*CONNESSIONE HTTP -------------------------------------- */  
$scope.connessione = function (){
    $http({method: 'GET', url: 'http://www.fattura.local/contatti.php'}).

    success(function(data, status, headers, config) {
        alert(data);        
    }).

    error(function(data, status, headers, config) {
        alert("errore.");
    });   };    }]);

My Php array:

<?php

$contatti = array('Mario Rossi, Via Cippina,1 - 10100 Torino','Giacomo Puccini, Via Cippella, 2 10100 Torino','Giuseppe Verdi, Via Aida, 14 10100 Torino','Nicolò Paganini, Via NonRipetibile, 33 10023 Chieri');
echo json_encode($contatti);
share|improve this question
    
Your exemple use the typeahead directive angular-ui.github.io/bootstrap/#/typeahead – Needpoule Apr 29 '14 at 10:34
    
I donk know how, but I solved it in this way: <textarea ng-model="selected" ng-click="connessione()" typeahead="contatti for contatti in contatti | filter:$viewValue"> <!-- $viewValue = "is the value that is entered by a user" google dixit--> </textarea> – Mariagrazia.B Apr 29 '14 at 14:36
up vote 1 down vote accepted

One good solution is datalist html tag. It has disadvantage of not being supported in safari and IE9 and older. But it is very clean HTML solution.

<input list="data" />
<datalist id="data">
    <option value="data1"></option>
    <option value="data2"></option>
    <option value="data3"></option>
    <option value="data4"></option>
    <option value="data5"></option>
</datalist>
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.