Created
December 15, 2013 18:58
-
-
Save kvofreelance/7976710 to your computer and use it in GitHub Desktop.
This file contains 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
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