1
I have two distinct functions, one searches for an id(works) the other searches for a character letter(works). I need these two functions to act together,?
When I select the id, which return the set belonging to that id it has to be possible to do another search on this set, now per Letter. I don’t know how to combine these methods.
$scope.byLetter = function (letter) {
$scope.unitsPromise =
$http
.get('/api/units.json?letter=' + letter)
.success(function (data) {
$scope.total_pages = data.total_pages;
$scope.units = data.units;
});
};
$scope.$watch('organ_id', function (newValue, oldValue, letter) {
if (newValue != null && newValue != '' && letter == null) {
$scope.unitsPromise =
$http
.get('/api/units.json?organ_id=' + newValue)
.success(function (data) {
$scope.units = data.units;
});
};
}, true);
These are the two methods, what searches by letter and what relates the set to the organ id.