AngularJS ng-使用ctrl +单击

时间:2018-05-29 04:04:21

标签: javascript angularjs codemirror

我创建了一个jsfiddle click here

但我无法弄清楚如何实现ctrl +点击选择选项。

在调用retrieveSelectedClass之后,在项目js文件中

,我有一些http请求从服务器端获取数据并在ui中显示它。我正在使用库来显示代码Codemirror

        var data = {
            apexClassName: $scope.selectedName.name
        };
        var config = {
            params: data
        };
        $http.get("/getApexBody", config).then(getApexBodyCallback, getApexBodyErrorCallback);

        function getApexBodyCallback(response) {
            if (response.data) {
                $scope.apexClassWrapper = response.data;
                if (globalEditor1) {
                    globalEditor1.toTextArea();
                }
                setTimeout(function(test) {
                    var editor = CodeMirror.fromTextArea(document.getElementById('apexBody'), {
                        lineNumbers: true,
                        matchBrackets: true,
                        styleActiveLine: true,
                        extraKeys: {
                            ".": function(editor) {
                                setTimeout(function() {
                                    editor.execCommand("autocomplete");
                                }, 100);
                                throw CodeMirror.Pass; // tell CodeMirror we didn't handle the key
                            }
                        },
                        gutters: ["CodeMirror-lint-markers"],
                        lint: true,
                        mode: "text/x-apex"
                    });
                    editor.markClean();
                    editor.on("keyup", function(cm, event) {
                        var keyCode = event.keyCode || event.which;
                        if (!ExcludedIntelliSenseTriggerKeys[(event.keyCode || event.which).toString()]) {
                            if (timeout) clearTimeout(timeout);
                            timeout = setTimeout(function() {
                                editor.showHint({
                                    hint: CodeMirror.hint.auto,
                                    completeSingle: false
                                });
                            }, 150);
                        }
                    });
                    globalEditor1 = $('.CodeMirror')[0].CodeMirror;
                }), 2000
                document.getElementById('saveBtn').style.visibility = 'visible';
                $scope.isPaneShown = false;
            }
        }

HTML

<div id="container">
    <select ng-model="selectedName" ng-change="retrieveSelectedClass(selectedName, '{{selectedName}}')" ng-options="item.name group by item.groupName for item in names"
            class="code-helper" id="code-helperId">
        <option value="">Select Option</option>
    </select>
</div>
<div style="padding: 1px; position: absolute; margin: 0px; left: 0px; right: 0px; top: 30px; bottom: 30px; width: 100%; height: auto; " loading-pane="isPaneShown">
<textarea ng-model="apexClassWrapper.body" id="apexBody" name="apexBody" style="display: none;" readonly="true">{{apexClassWrapper.body}}</textarea>

</div>

问题是即使我抓住这样的ctrl click事件:

if ($window.event.ctrlKey) {}

在我的retrieveSelectedClass内,如何在新标签页中打开相同的html页面,并在选择菜单中选择了选项值

但我无法理解如何实现ctrl +单击选项选择值以使其在新选项卡中打开,在选择下拉列表中选择文件名,文本区域显示检索到的正文类?

0 个答案:

没有答案