Angularjs angular.js中隐藏元素的延迟编译
我有一个相当复杂的angular.js应用程序,在同一页面上有一个显示模式和一个编辑模式。大多数复杂性都在编辑模式下,大多数用户永远不会处于编辑模式下 您可以在这里看到一个示例:但您将无法访问编辑模式。正如您将看到的,我的页面加载速度比理想的慢 在整个页面的许多地方,我都有整个复杂的嵌套部分,这些部分由 ng show=editModeAngularjs angular.js中隐藏元素的延迟编译,angularjs,angularjs-directive,Angularjs,Angularjs Directive,我有一个相当复杂的angular.js应用程序,在同一页面上有一个显示模式和一个编辑模式。大多数复杂性都在编辑模式下,大多数用户永远不会处于编辑模式下 您可以在这里看到一个示例:但您将无法访问编辑模式。正如您将看到的,我的页面加载速度比理想的慢 在整个页面的许多地方,我都有整个复杂的嵌套部分,这些部分由 ng show=editMode 有没有任何方法可以让我延迟编译整个子树,直到editMode变为true,或者至少直到页面的其余部分呈现出来?您可能可以使用和的组合 对于需要处理的部分,请使用
有没有任何方法可以让我延迟编译整个子树,直到editMode变为true,或者至少直到页面的其余部分呈现出来?您可能可以使用和的组合 对于需要处理的部分,请使用ng开关,而不是ng show: 然后,当切换到编辑模式时,填写这些模板值:
$scope.edit = function() {
$scope.editMode = true;
if ($scope.edittemplatesLoaded) return; // Don't set these twice
$scope.edittemplates.sectionFoo = 'sectionFoo.html';
$scope.edittemplates.sectionBar = 'sectionBar.html';
// etc.
$scope.edittemplatesLoaded = true;
};
因为src属性最初是空的,所以最初没有什么可编译的
我还没有尝试过这个,因为我还不需要类似的东西,但它应该可以工作。您可能可以使用和的组合 对于需要处理的部分,请使用ng开关,而不是ng show: 然后,当切换到编辑模式时,填写这些模板值:
$scope.edit = function() {
$scope.editMode = true;
if ($scope.edittemplatesLoaded) return; // Don't set these twice
$scope.edittemplates.sectionFoo = 'sectionFoo.html';
$scope.edittemplates.sectionBar = 'sectionBar.html';
// etc.
$scope.edittemplatesLoaded = true;
};
因为src属性最初是空的,所以最初没有什么可编译的
我还没有尝试过这个,因为我还不需要类似的东西,但它应该能工作。这是个聪明的主意!除非有人想出一个更简单的解决方案,否则我会试试看。嘿,嗯,这让我想。。。是否有可能创建一个类似noCompile=true的指令,以某种方式阻止递归下降,然后在准备就绪时将其切换为false?嗯……是的,我相信您可以通过向指令定义对象添加terminal:true来停止编译。这是一个聪明的主意!除非有人想出一个更简单的解决方案,否则我会试试看。嘿,嗯,这让我想。。。是否有可能创建一个类似noCompile=true的指令,以某种方式阻止递归下降,然后在准备就绪时将其切换为false?嗯……是的,我相信您可以通过向指令定义对象添加terminal:true来停止编译。
$scope.edit = function() {
$scope.editMode = true;
if ($scope.edittemplatesLoaded) return; // Don't set these twice
$scope.edittemplates.sectionFoo = 'sectionFoo.html';
$scope.edittemplates.sectionBar = 'sectionBar.html';
// etc.
$scope.edittemplatesLoaded = true;
};