Autocomplete with div text

0

I have a list of links, what I need is that when typing in a textbox this list is filtered by text, is it possible?

It would be a kind of autocomplete without a database.

    
asked by anonymous 24.08.2016 / 16:31

1 answer

0

The simplest way of doing what you need and using the JS angle, you should try to learn a bit more about this powerful javascript framework.

I leave an example below of how to do the function you need.

      <!DOCTYPE html>
      <html>
      <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script><body><scripttype="text/javascript">
              var app = angular.module('meuAPP', []);
              app.controller('meuControle', function($scope) {
                  $scope.listaDeSites = [
                    {site:"A",link:""},
                    {site:"AAB",link:""},
                    {site:"BB",link:""},
                    {site:"AVCD",link:""}
                  ];
              });
          </script>
          <div ng-app="meuAPP" ng-controller="meuControle">
              <input type="text" name="name" ng-model="filtro" value="">
              <ul ng-repeat="item in listaDeSites | filter:filtro">
                <li><a href="{{item.link}}">{{item.site}}</a></li>
              </ul>
          </div>
      </body>
      </html>
    
24.08.2016 / 17:48