<my-tabs>
<my-pane title="Hello">
<h4>Hello</h4>
<p>Lorem ipsum dolor sit amet</p>
</my-pane>
<my-pane title="World">
<h4>World</h4>
<em>Mauris elementum elementum enim at suscipit.</em>
<p><a href ng-click="i = i + 1">counter: {{i || }}</a></p>
</my-pane>
</my-tabs> 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 === ) {
$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'
};
}); my-tabs.html: <div class="tabbable">
<ul class="nav nav-tabs">
<li ng-repeat="pane in panes" ng-class="{active:pane.selected}">
<a href="" ng-click="select(pane)">{{pane.title}}</a>
</li>
</ul>
<div class="tab-content" ng-transclude></div>
</div> my-pane.html:
<div class="tab-pane" ng-show="selected" ng-transclude>
</div>
angular.module('docsTabsExample', [])
.directive('myPane', function() {
return {
require: ['^myTabs', '^ngModel'],
restrict: 'E',
transclude: true,
scope: {
title: '@'
},
link: function(scope, element, attrs, controllers) {
var tabsCtrl = controllers[0],
modelCtrl = controllers[1]; tabsCtrl.addPane(scope);
},
templateUrl: 'my-pane.html'
};
});

Creating Directives that Communicate的更多相关文章

  1. Directive Definition Object

    不知道为什么这个我并没有想翻译过来的欲望,或许我并没有都看熟透,不好误人子弟,原版奉上. Here's an example directive declared with a Directive D ...

  2. Scope Directive

    ---------------------------Scope-------------------------------- https://docs.angularjs.org/guide/sc ...

  3. How to use data analysis for machine learning (example, part 1)

    In my last article, I stated that for practitioners (as opposed to theorists), the real prerequisite ...

  4. Angular之 Scope和 Directive

    ---------------------------Scope-------------------------------- https://docs.angularjs.org/guide/sc ...

  5. 【C/C++开发】c++ 工具库 (zz)

    下面是收集的一些开发工具包,主要是C/C++方面的,涉及图形.图像.游戏.人工智能等各个方面,感觉是一个比较全的资源.供参考!  原文的出处:http://www.codemonsters.de/ho ...

  6. 【IOS笔记】Creating Custom Content View Controllers

    Creating Custom Content View Controllers 自定义内容视图控制器 Custom content view controllers are the heart of ...

  7. Redis(7)Creating and Using Cluster Mode

    1. DocumentsCluster will not support SELECT, it only contains database 0.All the nodes use TCP bus a ...

  8. Creating an API-Centric Web Application[转]

    Creating an API-Centric Web Application 转自 http://hub.tutsplus.com/tutorials/creating-an-api-centric ...

  9. Creating Your Own Server: The Socket API, Part 1

    转:http://www.linuxforu.com/2011/08/creating-your-own-server-the-socket-api-part-1/ By Pankaj Tanwar  ...

随机推荐

  1. C#5.0 .net 4.5示例

    //filename: MathOperations.cs using System; using System.Collections.Generic; using System.Linq; usi ...

  2. IdTcpClient简单示例

    procedure TForm1.btnHttpGetClick(Sender: TObject); begin idtcpclnt1.Host := '192.168.10.88'; idtcpcl ...

  3. httpclient提交json参数

    private void httpReqUrl(List<HongGuTan> list, String url) throws ClientProtocolException, IOEx ...

  4. ArcMap打开越来越慢

    原文:ArcMap打开越来越慢 今天终于找到原因了,原来是 C:\Users\Administrator\AppData\Roaming\ESRI\Desktop10.1\ArcToolbox下 Ar ...

  5. Selenium2学习-018-WebUI自动化实战实例-016-自动化脚本编写过程中的登录验证码问题

    日常的 Web 网站开发的过程中,为提升登录安全或防止用户通过脚本进行黄牛操作(宇宙最贵铁皮天朝魔都的机动车牌照竞拍中),很多网站在登录的时候,添加了验证码验证,而且验证码的实现越来越复杂,对其进行脚 ...

  6. JavaScript:JavaScript事件的处理

    JavaScript事件处理 —————事件的处理流程: —————动态事件绑定: —————常用的事件处理. 1.事件的概念 在页面之中,会针对用户的每一个操作进行记录.在页面中的事件可以简单的理解 ...

  7. 微信公众平台自定义菜单及高级接口PHP SDK

    本文介绍介绍微信公众平台自定义菜单及高级接口的PHP SDK及使用方法. 作者 方倍工作室 修正记录: 2014.05.03 v1.0 方倍工作室 http://www.cnblogs.com/txw ...

  8. 微信小店开发(2) DIY货架

    微信小店的货架支持开放给开发者使用,即开发者可以将自己的页面作为货架,通过JavaScript API来调起微信客户端原生的商品详情页. 请注意:1. 开发者需要预先通过1.1中的增加商品API,预先 ...

  9. 楼市、股市后下一届ZF将用什么去做超发货币的蓄水池(

    这是天涯论坛上最近的的一个热帖合集,周小川曾直言超发货币需要蓄水池来装,以控制通货膨胀.这个蓄水池楼市做过.股市曾经也充当过,或许现在的地下钱庄也算一部分吧,那下一届政府会如何选择这个蓄水池呢,这或将 ...

  10. 查看mysql的版本

    查看mysql的版本 查看版本信息 http://www.jb51.net/article/36370.htm#1使用命令行模式进入mysql会看到最开始的提示符 Your MySQL connect ...