Skip to content

Instantly share code, notes, and snippets.

@kvofreelance
Created December 15, 2013 18:58
Show Gist options
  • Save kvofreelance/7976710 to your computer and use it in GitHub Desktop.
Save kvofreelance/7976710 to your computer and use it in GitHub Desktop.
https://github.com/Siyfion/angular-typeahead использовал это
верстка элемента
<input type="text" class="sfTypeahead" datasets="tempIngridientsList" ng-model="newIngridient"></input>
контроллер
--------------
// при первой загрузке
$scope.tempIngridientsList = {
name: 'accounts',
local: ['test1', 'test2']
};
--------------
// При изменеия текста в input
$scope.$watch('newIngridient', function() {
parameters = {};
parameters.query = $scope.newIngridient;
$http.post('/search/ingredient', parameters)
.success(function (data) {
for (var i = 0; i < data.length; i++) {
$scope.tempIngridientsList.local.push(data[i]._id);
};
})
.error(function (data, status, headers, config) {
console.log("Ingridient search error. Status: " + status + "; data: " + data + "; headers: " + headers + "; config: " + config);
});
});
Выпадающий список показует только test1 и test2, а новые значения нет
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment