下拉列表中的值不会更新

时间:2017-01-11 08:50:08

标签: javascript angularjs

我在我的下拉列表中使用搜索。但是当我在搜索中输入一个值时,它不会被选中。更改会被调用两次。并且旧值已更新。

例如,如果我在选择框中输入印度,早些时候是阿富汗。价值将保持在阿富汗。

    <ui-select id="country" class="ui-select-integration-style" ng-model="quoteRequest.quotationRequestItems[0].localSite.countryCode3" theme="select" ng-disabled="disabled" style="min-width: 220px;"
                             ng-change="displayCountryName($select.search);changeCountryName(quoteRequest.quotationRequestItems[0].localSite); updateBillingInSameCountryBlock();detectChange('countryName');updateLocalContact(quoteRequest.quotationRequestItems[0].localSite.countryCode3)" name="countryName" required>
                    <ui-select-match placeholder="Select a country in the list...">{{$select.selected.countryName}}</ui-select-match>
                    <ui-select-choices repeat="(countryCode3, country) in countries | filter: {countryName: $select.search}">
                      <div ng-bind-html="country.countryName | highlight: $select.search"></div>
                    </ui-select-choices>
                  </ui-select>

  $scope.changeCountryName = function (site) {
    console.log(site.countryCode3 +"COUNTRY CODE");
    $scope.changeCalled = true;


    site.countryName = $scope.countriesMap[site.countryCode3];
    //$scope.quoteRequest.quotationRequestItems[0].localSite.countryCode3 = site.countryCode3;

    console.log(site.countryName +"COUNTRY NAME");

  };



     //update billing in same country block if value is Yes
      $scope.updateBillingInSameCountryBlock = function(){
        if($scope.quoteRequest.quotationRequestItems[0].billingInSameCountry) {
          if($scope.quoteRequest.quotationRequestItems[0].localSite !== null){
            $scope.quoteRequest.quotationRequestItems[0].preferredBillingCountryCode = $scope.quoteRequest.quotationRequestItems[0].localSite.countryCode3;
            if( $scope.quoteRequest.quotationRequestItems[0].preferredBillingCity == $scope.oldCityValue){
              //we synchronize cities only if billing city has not been manually modified before
              $scope.quoteRequest.quotationRequestItems[0].preferredBillingCity = $scope.quoteRequest.quotationRequestItems[0].localSite.city;
            }
            $scope.oldCityValue = $scope.quoteRequest.quotationRequestItems[0].localSite.city;
          } else{
            $scope.resetBillingInSameCountryBlock();
          }
        }

      };


    $scope.updateLocalContact = function(countryCodeISO3){
        // set country selected by user in rootScope to make it available to the directive
        $rootScope.deliverySiteCountry = countryCodeISO3;

        // convert country code from ISO3 to ISO2 for use with phone plugin
        $rootScope.selectedCountryISO2 = "";
        $rootScope.selectedCountryISO2 = $rootScope.countryCode3Code2Map[countryCodeISO3];
        $scope.changeCalled = false;

        $scope.hideAllPhoneValidationMessages();

        if(!($scope.quoteRequest.quotationRequestItems[0].localSite.fetchedFromCore && !$scope.quoteRequest.quotationRequestItems[0].localSite.siteModified)){
          $('#'+myConstants.primaryPhone).trigger("change");
          $('#'+myConstants.primaryMobilePhone).trigger("change");
          $('#'+myConstants.secondaryPhone).trigger("change");
          $('#'+myConstants.secondaryMobilePhone).trigger("change");
        }
      }

0 个答案:

没有答案