Answer the question
In order to leave comments, you need to log in
How to dynamically change ng-model values?
I'm trying to make a simple autocoplete, maybe not quite right but ....
here is my html code:
<input type="search" placeholder="Search" ng-model="stationSearch">
<button class="button" ng-click="setStation(bn.name)" ng-repeat="bn in itemsList | filter:stationSearch">
{{bn.name}}
</button>
$scope.stationSearch = '';
$scope.setStation = function(bnn){
$scope.stationSearch = '';
$scope.stationSearch = bnn;
};
$scope.itemsList = [
{'name': 'Iapetos Baltazar', 'amount': 1},
{'name': 'Mordred Maui', 'amount': 4},
{'name': 'Verethragna Tane', 'amount': 20},
{'name': 'Arawn Lir', 'amount': 7},
{'name': 'Cepheus Zephyrus', 'amount': 15},
{'name': 'Leander Pallas', 'amount': 9},
{'name': 'Chryses Vohu Manah', 'amount': 13},
{'name': 'Nuadha Lycus', 'amount': 19}
];
Answer the question
In order to leave comments, you need to log in
My problem was solved after I made "stationSearch" object
$scope.stationSearch = {}
and
ng-model="stationSearch.val"
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question