使用元素指令来组织html是不好的做法吗?

时间:2021-02-14 00:02:29

Is it bad practice to use directives just to organize html?

使用指令只是为了组织html是不好的做法?

A simple example:

一个简单的例子:

<header></header>
<sidebar></sidebar>
<main-content></main-content>
<footer></footer>

Each directive would just have the templateUrl attribute defined, nothing more. A project I'm currently working on would have perhaps 10-15 of these directives. I'm not sure if this is abusing directives or if it would have a negative impact on the loading time of the page.

每个指令都只定义了templateUrl属性,仅此而已。我目前正在开展的一个项目可能会有10到15个这样的指令。我不确定这是否滥用指令或是否会对页面的加载时间产生负面影响。

Thanks.

1 个解决方案

#1


2  

Development wise, it makes sense. Production wise, make sure you combine them to one file using a task manager in order to minimize the number of requests. Also, it will help you couple directives + controllers in a consistent way.

发展明智,这是有道理的。生产方面,请确保使用任务管理器将它们合并到一个文件中,以便最大限度地减少请求数量。此外,它将帮助您以一致的方式耦合指令+控制器。

#1


2  

Development wise, it makes sense. Production wise, make sure you combine them to one file using a task manager in order to minimize the number of requests. Also, it will help you couple directives + controllers in a consistent way.

发展明智,这是有道理的。生产方面,请确保使用任务管理器将它们合并到一个文件中,以便最大限度地减少请求数量。此外,它将帮助您以一致的方式耦合指令+控制器。