Directive can use another directive though 'require' keyword.

angular.module('docsTabsExample', [])
.directive('myTabs', function() {
return {
restrict: 'E',
transclude: true,
scope: {},
controller: function($scope) {
var panes = $scope.panes = []; $scope.select = function(pane) {
angular.forEach(panes, function(pane) {
pane.selected = false;
});
pane.selected = true;
}; this.addPane = function(pane) {
if (panes.length === 0) {
$scope.select(pane);
}
panes.push(pane);
};
},
templateUrl: 'my-tabs.html'
};
})
.directive('myPane', function() {
return {
require: '^myTabs',
restrict: 'E',
transclude: true,
scope: {
title: '@'
},
link: function(scope, element, attrs, tabsCtrl) {
tabsCtrl.addPane(scope);
},
templateUrl: 'my-pane.html'
};
});

The myPane directive has a require option with value ^myTabs. When a directive uses this option, $compile will throw an error unless the specified controller is found. The ^ prefix means that this directive searches for the controller on its parents (without the ^ prefix, the directive would look for the controller on just its own element).

[AngularJS] Directive using another directive by 'require'的更多相关文章

  1. angularjs可交互的directive

    angularjs可交互的directive http://jsfiddle.net/revolunet/s4gm6/ directive开发上手练手,以注释的方式说明 html <body n ...

  2. AngularJS系统学习之Directive(指令)

    本文转自https://www.w3ctech.com/topic/1612 原文作者: Nicolas Bevacqua 原文:AngularJS’ Internals In Depth, Part ...

  3. AngularJS入门心得1——directive和controller如何通信

    粗略地翻了一遍<JavaScript DOM编程艺术>,就以为可以接过AngularJS的一招半式,一个星期过去了,我发现自己还是Too Young,Too Simple!(刚打照面的时候 ...

  4. AngularJS创建新指令directive参数说明

    var myapp = angular.module('myapp', []); myapp.directive('worldname', function() { return { template ...

  5. AngularJs(Part 11)--自定义Directive

    先对自定义Directive有一个大体的映像 myModule.directive('myDirective',function(injectables){ var directiveDefiniti ...

  6. [AngularJS + Unit Testing] Testing Directive's controller with bindToController, controllerAs and isolate scope

    <div> <h2>{{vm.userInfo.number}} - {{vm.userInfo.name}}</h2> </div> 'use str ...

  7. angularjs学习笔记三——directive

    AngularJS 通过被称为 指令 的新属性来扩展 HTML. 正如你所看到的,AngularJS 指令是以 ng 作为前缀的 HTML 属性. HTML5 允许扩展的(自制的)属性,以 data- ...

  8. 利用angularJs自定义指令(directive)实现在页面某一部分内滑块随着滚动条上下滑动

    最近老大让我一个效果实现在页面某一部分内滑块随着滚动条上下滑动,说明一下我们项目使用技术angularJs.大家都知道,使用jquery很好实现. 那么angular如何实现呢,我用的是自定义指令(d ...

  9. angularJs自定义指令(directive)实现滑块滑动

    最近老大让我一个效果实现在页面某一部分内滑块随着滚动条上下滑动,说明一下我们项目使用技术angularJs.大家都知道,使用jquery很好实现. 那么angular如何实现呢,我用的是自定义指令(d ...

随机推荐

  1. 2.Linq实用性技巧篇

    在论坛上经常会看到别人问,linq怎么实现递归,如何求笛卡尔积等问题..都可以用linq快速方便的解决..下面我就来个总的归纳 1.)递归 我们经常会遇到一个情况,就是想获取当前节点下的所有子节点.比 ...

  2. ckeditor+jsp+spring配置图片上传

    CKEditor用于富文本输入是极好的,它还有一些插件支持扩展功能,其中图片上传就是比较常用到的.本文简单记录我的实现步骤. 1.CKEditor除了提供三种标准版压缩包下载,还可根据自己的需求进行个 ...

  3. asp.net MVC 安全性[笔记]

    1. 跨站脚本(XSS) 1.1 介绍 1.1.1 被动注入,利用输入html,javascript 等信息伪造链接,图片等使用提交信息,调转页面等 1.1.2 主动注入,黑客主动参与攻击,不会傻等倒 ...

  4. 将string转化为char*的方法

    在构造文件流变量时候发现,fstream的第一个参数,即文件路径必须是const char * 如: string s = "/home/user/1.txt"; fstream ...

  5. linux下安装pkg-config时遇到"glib-2.0>=2.16"的错

    解决办法 如报错提示所述,加上:--with-internal-glib 即 ./configure --with-internal-glib 参考链接: http://stackoverflow.c ...

  6. 高性能、高容错、基于内存的开源分布式存储系统Tachyon的简单介绍

    Tachyon是什么? Tachyon是一个高性能.高容错.基于内存的开源分布式存储系统,并具有类Java的文件API.插件式的底层文件系统.兼容Hadoop MapReduce和Apache Spa ...

  7. 机器学习中的数学(3)-模型组合(Model Combining)之Boosting与Gradient Boosting

    版权声明: 本文由LeftNotEasy发布于http://leftnoteasy.cnblogs.com, 本文可以被全部的转载或者部分使用,但请注明出处,如果有问题,请联系wheeleast@gm ...

  8. svn跳过某个目录

    svn up --set-depth exclude dir2 http://stackoverflow.com/questions/1439176/svn-can-you-remove-direct ...

  9. sys.default_constraints

    作为默认定义且 sys.objects.type = D 的每个对象在表中各对应一行, 该默认定义是作为 CREATE TABLE 或 ALTER TABLE 语句的一部分创建的, 而不是作为 CRE ...

  10. [转]python下很帅气的爬虫包 - Beautiful Soup 示例

    原文地址http://blog.csdn.net/watsy/article/details/14161201 先发一下官方文档地址.http://www.crummy.com/software/Be ...