AngularJs directive-link实例
来源:互联网 发布:qq飞车堕落天使数据 编辑:程序博客网 时间:2024/05/29 07:09
1.代码:
<body ng-app="myApp" > <my-expander title="标题部分"> <h5>中间内容部分</h5> </my-expander> <!--<div class="panel panel-primary" > <div class="panel-heading"></div> <div class="panel-body"></div> </div>--> <script></body>
var app = angular.module('myApp', []);app.directive('myExpander', function () { return { restrict: 'E', replace: true, transclude: true, scope: { title:'@' //如果使用= 双向绑定失败,因为replace=true 原始标签的title会被删除 }, template: '<div class="panel panel-primary" >' + ' <div class="panel-heading" ng-click="toggle()">{{title}}</div>' + '<div class="panel-body" ng-show="showMe" ng-transclude></div>', link: function (scope, element, attrs) { scope.showMe = false; scope.toggle = function toggle() { scope.showMe = !scope.showMe; if (scope.showMe) { scope.title = '点击关闭'; } else { scope.title = '点击展开'; } } } }});
0 0
- AngularJs directive-link实例
- angularjs directive link 属性 问题
- angularjs directive 实例 详解
- AngularJs directive指令实例
- AngularJs directive-controller实例
- angularjs之directive实例
- angularjs directive 实例 详解
- angularjs directive 实例 详解
- angularjs directive内部controller link函数理解
- AngularJs 指令directive之controller,link,compile
- AngularJs 指令directive之controller,link,compile
- AngularJs 指令directive之controller,link,compile
- AngularJS实例详解Directive(指令)机制
- 《AngularJS》5个实例了解Directive
- angularJS系列之指令directive应用实例
- angularJS directive中的controller和link function辨析
- AngularJS--directive
- angularjs directive
- 电商之梳理lucene相关知识---深度搜索
- 新生代与老年代
- java-字符串String类
- 如何关闭OSX 10.11 SIP
- maven build tomcat:run报错
- AngularJs directive-link实例
- 分治算法之归并排序
- 谈谈OpenStack的鉴权过程
- HDU2011
- jQuery选择器-可见性选择器示例
- 管理Android音频播放
- 电商之梳理MR/storm相关知识---计算
- 阿里云CentOS7安装Oracle11GR2
- 106-Search Insert Position