Last active
August 29, 2015 14:19
-
-
Save borntorun/7671ef832b7cbacb8255 to your computer and use it in GitHub Desktop.
Example file for http://borntorun.github.io/angular-remote-typeaheadjs/
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div ng-controller="RemotePrefetchCtrl as vm"> | |
<angular-typeaheadjs prefetch="{{vm.prefetch}}" | |
remote="{{vm.remote}}" | |
onselected="vm.onSelected" | |
onclosed="vm.onClosed" | |
oncursorchanged="vm.onCursorChanged" | |
datasource="countries" | |
placeholder="Search for Countries" | |
minlensugestion="1" | |
limit="9" | |
clearvalue="true" | |
cssinput="inputclass"/> | |
</div> | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
angular | |
.module('appdemo', ['angularTypeaheadjs']) | |
.controller('RemotePrefetchCtrl', [ '$scope', RemotePrefetchCtrl ]); | |
function RemotePrefetchCtrl() { | |
var vm = this; | |
vm.itemonSelected = []; | |
vm.prefetch = 'data/countries.json' | |
vm.remote = 'data/%QUERY.json'; | |
vm.onSelected = function (item) { | |
for(var i = vm.itemonSelected.length - 1; i >= 0; i--) { | |
if(vm.itemonSelected[i] === item.name) { | |
vm.itemonSelected.splice(i, 1); | |
} | |
} | |
vm.itemonSelected.push(item.name); | |
vm.itemonCursorChanged = ''; | |
}; | |
vm.onCursorChanged = function(item) { | |
vm.itemonCursorChanged = item.name; | |
}; | |
vm.onClosed = function() { | |
vm.itemonCursorChanged = ''; | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment