<!DOCTYPE HTML>
<html ng-app="myApp">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>无标题文档</title>
<style>
#div1 div,#div2 div{ width:200px; height:200px; border:1px red solid; display:none;}
#div1 input.active , #div2 input.active{ background:red;}
</style>
<script src="jquery-1.11.1.js"></script>
<script src="angular.min.js"></script>
<script> var m1 = angular.module('myApp',[]);
m1.directive('myTab',function(){
return {
restrict : 'E',
replace : true,
scope : {
myId : '@',
myData : '='
},
controller : ['$scope',function($scope){
$scope.name = 'miaov';
}],
templateUrl : 'temp3.html',
link : function(scope,element,attr){
//console.log(scope.name);
//console.log(element);
//console.log(attr.myId);
element.delegate('input','click',function(){
$(this).attr('class','active').siblings('input').attr('class','');
$(this).siblings('div').eq( $(this).index() ).css('display','block').siblings('div').css('display','none');
});
}
};
}); m1.controller('Aaa',['$scope',function($scope){ $scope.data1 = [
{title:'数学',content:'111111111'},
{title:'语文',content:'222222222'},
{title:'英语',content:'333333333'}
];
$scope.data2 = [
{title:'物理',content:'444444444'},
{title:'化学',content:'555555555'}
]; }]); </script>
</head> <body ng-controller="Aaa">
<my-tab my-id="div1" my-data="data1"></my-tab>
<my-tab my-id="div2" my-data="data2"></my-tab>
</body>
</html>

temp3.html

<div id="{{myId}}">
<!--<input class="active" type="button" value="1">
<input type="button" value="2">
<input type="button" value="3">
<div style="display:block">11111111</div>
<div>22222222</div>
<div>33333333</div>-->
<input ng-repeat="data in myData" type="button" ng-value="data.title" ng-class="{active:$first}">
<div ng-repeat="data in myData" ng-style="{display:$first?'block':'none'}">{{ data.content }}</div>
</div>

最新文章

  1. spring 的aop proxy 代理
  2. Saltstack 介绍、安装、配置(一)
  3. 【Solr】数据库数据导入索引库
  4. Topcoder SRM 626 DIV2 FixedDiceGameDiv2
  5. 一步步调试解决iOS内存泄漏
  6. nodejs 执行shell 命令
  7. python27+django1.9创建app的视图及实现动态页面
  8. IOS开发之上传APP
  9. SSM框架+Plupload实现断点续传(Spring+SpringMVC+MyBatis+Plupload)
  10. floyd学习中
  11. Introduction to gaussian filter 高斯滤波器
  12. Oracle笔试题库之问答题篇-总共60道
  13. php银联网页支付实现方法
  14. 豹哥嵌入式讲堂:ARM开发之文件详解(4)- relocatable文件(object, library)
  15. js字符串轉數組,數組轉字符串
  16. 概率DP自学
  17. 使用MiniProfiler检测页面性能
  18. 关于c++中前++后++运算符重载问题
  19. IDEA spirng boot @Autowired注解 mapper出现红色下划线解决方法
  20. linq在获取部门层级树种的应用

热门文章

  1. [fjwc2015]Screen [从hzw神犇那里扒来的题]
  2. 汕头市队赛 SRM 08 A
  3. C++虚函数表解析(基础篇)
  4. linux内核情景分析之execve()
  5. Kubernetes DNS安装配置
  6. spark streaming 异常No output streams registered, so nothing to execute
  7. springMVC 配置中易犯的小错误
  8. 最近有点把b/s架构什么的,和web发展搞晕了,现在来总结总结
  9. Java进阶之路,技术要点
  10. 设计模式-python实现