标签:
本人初学者,如有不足虚心求教!
angular指令的模块可以分下面几个部分:
下面一个简单的例子:
angular.module(‘expanderModule‘, []) .directive(‘expander‘, function(){ return { restrict: ‘EA‘, replace: true, transclude: true, scope: { title:‘=expanderTitle‘ }, template: ‘<div>‘ + ‘<div class="title" ng-click="toggle()">{{title}}</div>‘ + ‘<div class="body" ng-show="showMe" ng-transclude></div>‘ + ‘</div>‘, link: function(scope, element, attrs) { scope.showMe = false; scope.toggle = function toggle() { scope.showMe = !scope.showMe; } } } });
标签:
原文地址:http://www.cnblogs.com/2014-1130/p/4740897.html