[英]Call function after DOM is updated by angular
I have a function that toggle variable that show search panel and I need to call resize function when panel is visible to refresh ACE editor (the panel make editor smaller). 我有一个切换显示搜索面板的变量的函数,当面板可见时我需要调用resize函数来刷新ACE编辑器(面板使编辑器变小)。
in html I have: 在html中,我有:
<div class="search-panel" ng-show="searchReplace">
<button type="button" ng-click="search(false)" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<form name="searchForm">
...
and my search function look like this: 我的搜索功能如下所示:
var prev_search;
$scope.search = function(toggle, replace) {
var refresh = $scope.searchReplace != toggle;
if (toggle) {
if ($scope.searchReplace) {
// next search
if ($scope.selectedSearchText != prev_search) {
// new search
} else {
// continue
}
} else {
$scope.searchReplace = true;
$scope.replaceMode = !!replace;
}
} else {
$scope.searchReplace = false;
}
if (refresh) {
editor.resize();
}
};
I call that function in keydown event: 我在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并在之后调用了调整大小。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.