For building an HTML template with reusable widgets like header, sidebar, footer, etc. Basically the main content is the central DIV which will have its content varying between routes, header and footer will be almost always the same, sidebar can vary in certain pages.

Based on the your page structure, at least for headers and footers you do not need to use directives, there would be only single rendering for these controls. Standard ng-include with a partial and maybe a linked controller would do. Remember ng-include itself is a directive.

Directive would be useful where you want a component that needs to used across pages, your headers and footer nav do not fit this bill as there is a single instance of these elements on the page.

But I prefer directives because ng-include only breaks down the view part into smaller modules. By using directives, even if it is used only once, you still nicely modularize your page into smaller independent components. Markup of the parent page looks much nicer and you don't have to clutter your controller with more methods.

AngularJS Best Practices: ng-include vs directive的更多相关文章

  1. angular 中怎么获取路径上的参数 参考:https://docs.angularjs.org/api/ng/service/$location

    参考: https://docs.angularjs.org/api/ng/service/$location

  2. Part 16 ng include directive in AngularJS

    ng-include directive is used to embed an HTML page into another HTML page. This technique is extreme ...

  3. AngularJS Best Practices: SEO

    Google can execute AJAX & JavaScript for indexing, you can read the below link for more detailed ...

  4. AngularJS Best Practices: pretty urls

    By default, AngularJS will route URLs with a hashtag. For example: http://example.com/ http://exampl ...

  5. AngularJS Best Practices: ngRoute

    app/----- components/---------- users/--------------- controllers/-------------------- users.control ...

  6. Angularjs checkbox的ng属性

    angularjs 默认给 input[checkbox] 元素定制了一些属性,如: <input type="checkbox" ng-mudel="name&q ...

  7. 在AngularJS中实现一个延迟加载的Directive

    所谓的延迟加载通常是:直到用户交互时才加载.如何实现延迟加载呢? 需要搞清楚三个方面: 1.html元素的哪个属性需要延迟加载?2.需要对数据源的哪个字段进行延迟加载?3.通过什么事件来触发延迟加载? ...

  8. angularjs 与 UEditor开发,添加directive,保证加载顺序正常

    'use strict'; angular.module('app.core').directive('ueditor', [function () { return { restrict: 'A', ...

  9. AngularJS Best Practices: resource

    A factory which creates a resource object that lets you interact with RESTful server-side data sourc ...

随机推荐

  1. 你不知道的parseInt

      首先,请允许我抄袭一段你知道的parseInt   以下节选自parseInt - JavaScript | MDN 实际上你连这些基础都没掌握 概述 parseInt() 函数将给定的字符串以指 ...

  2. [python学习] 语言基础—排序函数(sort()、sorted()、argsort()函数)

    python的内建排序函数有 sort.sorted两个. 1.基础的序列升序排序直接调用sorted()方法即可 ls = list([5, 2, 3, 1, 4]) new_ls = sorted ...

  3. python 之 前端初识 html

    html语法代码示例 <!DOCTYPE html> <html lang="en"> <head> <meta charset=&quo ...

  4. C# Questions

    What's the difference between linkedlist and array? How do you implement linkedlist? What's the diff ...

  5. phpcmsv9多表联合查询分页功能实现

    phpcms v9里面自带的listinfo分页函数蛮好用的,可惜啊.不支持多表查询并分页. 看了一下前台模板层支持get标签,支持多表查询,支持分页.刚好可以把这个功能搬到后台来使用. 我们现在对g ...

  6. 一些关于Viewport与device-width的东西~

    进行移动web开发已经有一年多的时间了,期间遇到了一些令人很困惑的东西.比如: 我们经常使用的<meta name="viewport" content="widt ...

  7. JQuery实现方法,简单示例

    function $() { var elements = new Array(); for (var i = 0; i < arguments.length; i++) { var eleme ...

  8. DOS 命令For精解示例

    最基本形态: 在cmd 窗口中:for %I in (command1) do command2 在批处理文件中:for %%I in (command1) do command2 在批处理中,FOR ...

  9. jQuery文本段落展开和折叠效果

    <!DOCTYPE html> <head> <meta http-equiv="Content-Type" content="text/h ...

  10. InnoDB与Myisam的六大区别

    MyISAM     InnoDB   构成上的区别:   每个MyISAM在磁盘上存储成三个文件.第一个文件的名字以表的名字开始,扩展名指出文件类型. .frm文件存储表定义. 数据文件的扩展名为. ...