angucomplete-alt icon indicating copy to clipboard operation
angucomplete-alt copied to clipboard

InitialValue fires one time

Open bonucci opened this issue 7 years ago • 4 comments

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">

bonucci avatar Mar 30 '17 11:03 bonucci

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); } });

LuizSmuk avatar Oct 02 '17 20:10 LuizSmuk

@bonucci see #470

jeffersondev avatar Dec 03 '17 02:12 jeffersondev

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

elialbert avatar Jun 18 '18 20:06 elialbert

Grato,

Luiz Smuk.

FullStack Developer (.NET)


De: monster [email protected] Enviado: segunda-feira, 18 de junho de 2018 17:51 Para: ghiden/angucomplete-alt Cc: LuizSmuk; Comment Assunto: Re: [ghiden/angucomplete-alt] InitialValue fires one time (#482)

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

— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://github.com/ghiden/angucomplete-alt/issues/482#issuecomment-398191308, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ACOX3DmrracXKaLbj_1VqFMP1Vxdtj2fks5t-BK0gaJpZM4MuQPg.

LuizSmuk avatar Jun 19 '18 14:06 LuizSmuk