选中的选项未突出显示

时间:2015-03-16 05:37:21

标签: html angularjs select

当我删除任何选项时,我预先选择'产品'。即使选中它也不会突出显示。一个有价值的新选择"? string:{{lastSelectedOption}}?"正在出现。

  

Html

 <select class="mapping-select" id="SelectId" ng-model="table" name="classesList" size="20" >
                <!-- <option value="? string:{{selectedTable}} ?" style="display:none"></option> -->
                <option value="" style="display:none" ></option>
                <option value="Product" ng-click="selectTable('Product', 'Product')" ng-selected="preSelect">Product</option>
                <optgroup style="font-style: normal;" label="Prices">
                            <option value="{{pa.table}}" id="com.jcatalog.product.Prices:{{$index}}" ng-repeat="pa in tableLists.PricesList track by $index" ng-click="selectTable('Prices', 'Price', $index, tableLists.PricesList)">
                                {{pa.table}}({{$index+1}})
                            </option>
                </optgroup>
                <optgroup style="font-style: normal;" label="ProductAttributeValues">
                            <option value="{{pav.table}}" id="com.jcatalog.product.ProductAttributeValue:{{$index}}" ng-repeat="pav in tableLists.ProductAttributeValuesList track by $index" ng-click="selectTable('ProductAttributeValues', 'ProductAttributeValue', $index, tableLists.ProductAttributeValuesList)">
                                {{pav.table}}({{$index+1}})
                            </option>
                    </optgroup>
                    <optgroup style="font-style: normal;" label="ClassificationAssignment">
                            <option value="{{cg.table}}" id="com.jcatalog.product.ClassificationAssignment:{{$index}}" ng-repeat="cg in tableLists.ClassificationAssignmentsList track by $index" ng-click="selectTable('Product2ClassificationGroup', 'ClassificationAssignment', $index, tableLists.ClassificationAssignmentsList)">
                                {{cg.table}}({{$index+1}})
                            </option>
                    </optgroup>
                    <optgroup style="font-style: normal;" label="ProductRelations">
                            <option value="{{pr.table}}" id="com.jcatalog.product.ProductRelations:{{$index}}" ng-repeat="pr in tableLists.ProductRelationsList track by $index" ng-click="selectTable('ProductRelations', 'ProductRelation', $index, tableLists.ProductRelationsList)">
                                {{pr.table}}({{$index+1}})
                            </option>
                    </optgroup>
                    <optgroup style="font-style: normal;" label="ContractedProduct">
                            <option value="{{cp.table}}" id="com.jcatalog.product.ContractedProduct:{{$index}}" ng-repeat="cp in tableLists.ContractedProductList track by $index" ng-click="selectTable('ContractedProduct', 'ContractedProduct',$index, tableLists.ContractedProductList)">
                                {{cp.table}}({{$index+1}})
                            </option>
                    </optgroup>
                </select>
  

选项删除

$scope.selectTable = function (tname, otname, rowNo, list) {
  getTableData(tname, otname);
  $scope.selectedTable = otname;
  $scope.rowId = rowNo+1;
  $scope.selectedTableList = list;
}

$scope.acceptDeletetion = function () {
      var id;
      if($scope.selectedTable != 'Product'){
        if($scope.selectedTable && $scope.rowId){
          id = $scope.rowId;
          $scope.selectedTableList.splice(id-1, 1);
          updateList($scope.selectedTable, id);
            $scope.preSelect = true;
        } 
      } else {
        growl.error("You can't delete Product table");
      } 
    }

First image shows how select tag is looking when option is deleted

Second image shows Product option selection

任何人都可以帮助我为什么这个新的动作正在增加,我该如何避免呢?

1 个答案:

答案 0 :(得分:1)

一旦我删除了下拉列表中的ng-model="table"指令,错误就消失了。

  

我认为模型名table值产生的问题在加载时没有定义,所以它需要一个对象,并且它为你的下拉列表设置一个默认值,所以你有一个空格**(你可以在渲染的html代码中看到未定义的值,见下图)**。这是一个问题。祝好运 。

enter image description here

相关问题