How to do a search in a set passing the character as a parameter in JavaScript?

1

I have two distinct functions, one does one search for one id (works) another does one search for a letter character (it works). I need these two functions to work together, like?

When I select the id, which return the set belonging to that id has to be possible to do another search in this set, now per letter . I do not know how to put these methods together.

$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, which search by letter and what relates the set to the organ id.

    
asked by anonymous 27.10.2017 / 15:35

0 answers