0

I have this directive:

angular.module('core.auto-complete').directive("autocompleteLigation",
    [ '$http', 'LoginInfo', function($http, LoginInfo) {
        return {
            restrict : "A",
            require : "ngModel",
            link : function(scope, elem, attrs, ngModelCtrl) {
                var updateModel = function(dateText) {
                    scope.$apply(function() {
                        ngModelCtrl.$setViewValue(dateText);
                    });
                };
                var parameters = {
                    app_id : LoginInfo.app,
                    type : "ligations"
                };
                $http({
                    method : 'GET',
                    url : 'http://localhost:8080/getAutoCompleteInfo',
                    params : parameters
                }).then(function successCallback(response) {
                    var options = {
                        source : response.data,
                        select : function(event, ui) {
                            updateModel(ui.value);
                        }
                    };
                    elem.autocomplete(options);
                });
            }
        }
    } ]);

But i want to get the type value from parameters dynamically from an input text with an ng-model. In another words i want to get the autocomplition list of values based on another text input.

Edit: I Think i put low information.

<div class="form-group col-lg-4">
  <label>Source table Data Base</label>
  <input  type="text" class="form-control"
          ng-model="form.db_source"
          autocomplete-databases="{{form.liga_source}}" required>
</div>

I want the value of type in the parameters to be the value passed to autocomplete-databases which is a ng-model of another input text.

georgeawg
  • 48,608
  • 13
  • 72
  • 95
  • Possible duplicate of [AngularJS : Clear $watch](http://stackoverflow.com/questions/14957614/angularjs-clear-watch) – Aravind May 20 '17 at 19:27
  • Use the [`ng-change` directive](https://docs.angularjs.org/api/ng/directive/ngChange) in templates or add a function to [`ngModelCtrl.$viewChangeListeners`](https://docs.angularjs.org/api/ng/type/ngModel.NgModelController#$viewChangeListeners) array inside a directive. – georgeawg May 21 '17 at 05:35

0 Answers0