Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/420.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 在DOM被angular更新后调用函数_Javascript_Angularjs_Ace Editor - Fatal编程技术网

Javascript 在DOM被angular更新后调用函数

Javascript 在DOM被angular更新后调用函数,javascript,angularjs,ace-editor,Javascript,Angularjs,Ace Editor,我有一个切换显示搜索面板的变量的函数,当面板可见时,我需要调用resize函数来刷新ACE编辑器(面板使编辑器变小) 在html中,我有: <div class="search-panel" ng-show="searchReplace"> <button type="button" ng-click="search(false)" class="close" data-dismiss="modal" aria-hidden="true">&times;&

我有一个切换显示搜索面板的变量的函数,当面板可见时,我需要调用resize函数来刷新ACE编辑器(面板使编辑器变小)

在html中,我有:

<div class="search-panel" ng-show="searchReplace">
    <button type="button" ng-click="search(false)" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
    <form name="searchForm">
        ...
我在keydown事件中调用该函数:

$(document.documentElement || window).keydown(function(e) {
    if (e.ctrlKey) {
        if (e.which == 82) { // CTRL+R
            $scope.$apply(function() {
                $scope.search(true, true);
            });
        } else if (e.which == 81) { // CTRL+Q to test resize - it's working
            editor.resize();
        } else if (e.which == 70) { // CTRL+F
            $scope.$apply(function() {
                $scope.search(true);
            });
            e.preventDefault();
        }
    }
});

我最后使用了jQuery show/hide and call resize after。

在Angular中不应该使用直接的keydown事件,而应该使用ng keydown。@ZekeSonxx如何将keydown添加到整个文档?@ZekeSonxx我已将ng keydown添加到正文中,并且在更改DOM后不会调用resize。
$(document.documentElement || window).keydown(function(e) {
    if (e.ctrlKey) {
        if (e.which == 82) { // CTRL+R
            $scope.$apply(function() {
                $scope.search(true, true);
            });
        } else if (e.which == 81) { // CTRL+Q to test resize - it's working
            editor.resize();
        } else if (e.which == 70) { // CTRL+F
            $scope.$apply(function() {
                $scope.search(true);
            });
            e.preventDefault();
        }
    }
});