Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

InitialValue fires one time #482

Open
bonucci opened this issue Mar 30, 2017 · 4 comments
Open

InitialValue fires one time #482

bonucci opened this issue Mar 30, 2017 · 4 comments

Comments

@bonucci
Copy link

bonucci commented Mar 30, 2017

I notice after i populate data from one input to another, the initialValue only fires one time when is empty, is like after is filled, if the $scope.test value is changed after the operating_airline input doesnt change anymore.

controller:

$scope.automaticFill = function(){
    var str = $scope.claim.flight_details.flight_code;
if(str.length >= 2){
          console.log("Im changed");
       $http.get('data/airlines-companies.json').then(function(response){
           
        var airlines = response.data; 
           
            airlines.forEach(function(code) {
            if(code.code_airline === str.toString().substring(0, 2).toUpperCase())
             $scope.test = code;
            });
        });
          
      }
};    
    

Html:

<input type="text" 
                               class="form-control" 
                               ng-model="claim.flight_details.flight_code" 
                               name="flight_code" 
                               id="flight_code"
                               ng-change="automaticFill()">

<div angucomplete-alt
                                  local-search="tap"
                                 id="operating_airline"
                                 placeholder="Search airline"
                                 pause="100"
                                 selected-object="claim.flight_details.operating_airline"
                                 local-data="airlines"
                                 search-fields="label"
                                 title-field="label"
                                 minlength="1"
                                 input-name="operating_airline"
                                 input-class="form-control form-control-small"
                                 match-class="highlight"
                                 field-required="true"
                                 initial-value="test">
@LuizSmuk
Copy link

LuizSmuk commented Oct 2, 2017

The solution I found was to remove the function that removes the watch from the innitial-value, at line 98 of the file until the 105 should be this code.

unbindInitialValue = scope.$watch('initialValue', function (newval) { if (newval) { // remove scope listener //unbindInitialValue(); // change input handleInputChange(newval, true); } });

@jeffersondev
Copy link

@bonucci see #470

@elialbert
Copy link

it sucks but if you don't want to fork the repo you can also use
$scope.$broadcast('angucomplete-alt:changeInput', elementId, value);

@LuizSmuk
Copy link

LuizSmuk commented Jun 19, 2018 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants