Angularjs下拉列表因ng焦点事件关闭

Angularjs下拉列表因ng焦点事件关闭,angularjs,html,Angularjs,Html,我有一张Angularjs的表格。我的下拉列表如下: <p ng-show="isCompoValMsgOn">'select component'</p> <select ng-focus="onFocusComponent($event)" id="component" ng-model="component.selected" ng-change="onSelectComponentCode()"> <option valu

我有一张Angularjs的表格。我的下拉列表如下:

   <p ng-show="isCompoValMsgOn">'select component'</p>
    <select ng-focus="onFocusComponent($event)"   id="component" ng-model="component.selected" ng-change="onSelectComponentCode()">
   <option value="">Select Component</option>
   <option ng-repeat="component   in  list value="{{component}}">{{ component.DES }}</option>
   </select>
现在我希望,一旦用户关注下拉列表,错误消息就会隐藏起来。为此,我编写了以下代码:

$scope.onFocusComponent = function ($event) {
        $scope.isCompoValMsgOn = false; 
    }
这是可行的,但也产生了另一个问题

问题就在这里: 只要我关注下拉菜单,错误消息就会隐藏,但下拉菜单也会关闭,并且选择了随机选项

但我的要求如下:

  • 错误消息应该隐藏

  • 下拉列表不应关闭,并让用户选择该选项

  • 这是你的问题:

    <option ng-repeat="component in list" value="{{component.DES}}">{{ component.DES }}</option>
    
    {{component.DES}
    
    缺少引号这是您的问题:

    <option ng-repeat="component in list" value="{{component.DES}}">{{ component.DES }}</option>
    
    {{component.DES}
    

    缺少引号

    我已找到上述问题的解决方案。我已使用ng click事件而不是ng focus事件。以下是代码:

    <select ng-click="onFocusComponent()" ng-disabled="!frmValidationParms.IsCepCodeSelected" class="form-control" name="component" id="component" ng-model="component.selected" ng-change="onSelectComponentCode()">
                                    <option value="">Select Component</option>
                                    <option ng-repeat="component   in component.projectListData.PCAT_OBJ.ARR_PCOM | orderBy:['ORD']" value="{{component}}">{{ component.DES }}</option>
                                </select>
    
    
    选择组件
    {{component.DES}
    
    我找到了上述问题的解决方案。我使用了ng click事件而不是ng focus事件。以下是代码:

    <select ng-click="onFocusComponent()" ng-disabled="!frmValidationParms.IsCepCodeSelected" class="form-control" name="component" id="component" ng-model="component.selected" ng-change="onSelectComponentCode()">
                                    <option value="">Select Component</option>
                                    <option ng-repeat="component   in component.projectListData.PCAT_OBJ.ARR_PCOM | orderBy:['ORD']" value="{{component}}">{{ component.DES }}</option>
                                </select>
    
    
    选择组件
    {{component.DES}
    
    Try ng if=“!isCompoValMsgOn”感谢您的回复。我仍然尝试了相同的问题。Try ng if=“!isCompoValMsgOn”感谢您的回复。我仍然尝试了相同的问题