Skip to content

cresjie/cjlTypeahead

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 

Repository files navigation

cjlTypeahead

A simple Angular.js directive wrapper around the Twitter Typeahead library.

Requirements

Usage

<body ng-controller="MyController">
  <input type="text" name="search" class="typeahead" cjl-typeahead="myTypeahead" typeahead-options="null" typeahead-datasets="typeaheadDatasets" placeholder="search user">
  <!--
    Directive: cjl-typeahead
      Attributes:
              * typeahead-options - this will be passed to the typeahead constructor
              * typeahead-datasets - this will be passed to the typeahead constructor
  -->
  </body>
  var app = angular.module('app',['cjl.typeahead']);
  app.controller('MyController',function($scope){
      
      $scope.$watch('typeahead',function(o,typeahead){
          // we name the directive "cjl-typeahead" - myTypeahead
          // use the method "$on" to add listeners to dom, jquery, typeahead events
					typeahead.myTypeahead.$on('typeahead:selected',function(e,selected){
						$scope.selectedData = selected;
					});

					typeahead.myTypeahead.$on('typeahead:cursorchange',function(e, selected, p){
						console.log(selected);
					});

				});
				
      $scope.typeaheadDatasets={
						display:['name'],
						source:function(q,cb){
							cb(users);
						}
				}
				
  });

About

angular typeahead

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published