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. TComboBox; 指定某一行,不给下拉,只读ReadOnly 伪装 实现

    //cbb1: TComboBox; 指定某一行,不给下拉,自读伪装 实现: cbb1.Style :=csSimple; //设定style 不可以下拉 cbb1.ItemIndex := ; // ...

  2. CSS Table Gallery

    http://icant.co.uk/csstablegallery/tables/99.php

  3. POJ 2431Expedition

    Description A group of cows grabbed a truck and ventured on an expedition deep into the jungle. Bein ...

  4. 【Unity3d游戏开发】Unity3D中的3D数学基础---向量

    向量是2D.3D数学研究的标准工具,在3D游戏中向量是基础.因此掌握好向量的一些基本概念以及属性和常用运算方法就显得尤为重要.在本篇博客中,马三就来和大家一起回顾和学习一下Unity3D中那些常用的3 ...

  5. MongoDB命令及SQL语法对比

    mongodb与mysql命令对比 传统的关系数据库一般由数据库(database).表(table).记录(record)三个层次概念组成,MongoDB是由数据库(database).集合(col ...

  6. js-倒计时自动隐藏

    <!doctype html><html><head><meta charset="utf-8"><title>无标题文 ...

  7. easy ui插件

    简介: easy UI是类似于jQuery UI的插件库 注意:多脚本同时使用时,注意脚本冲突问题. 常用插件: 1.tree插件(tree插件实现动态树形菜单) 2.datagrid插件(datag ...

  8. MySQL、mybatis的查询条件-时间段

    1.配置文件中的写法 <if test="startTime !=null and startTime !='' "> <![CDATA[ and createT ...

  9. SQL SERVER 合并重复行,行列转换

    引用自:http://www.cnblogs.com/love-summer/archive/2012/03/27/2419778.html sql server2000 里面如何实现oracle10 ...

  10. 项目:学生查看自己的作业情况和分数(php)

    <?php include '../includes/db.ini.php'; try { $sql='SELECT work_id,title,work_text,score_value FR ...