angular-directive

 

.directive('expander', function() {
    /*
    expander()
    restrict: E,A,C,M(元素,属性,样式,注释)
    transclude:true替换
    compile(编译)和link(连接)
    <expander class='expander' expander-title='title'></expander>

*/ var scope ={title : '=expanderTitle'}; var template = '<div><div class="title" ng-click="toggle()">{{title}}</div><div class="body" ng-show="showMe" ng-transclude></div></div>'; var link = function(scope, element, attrs){ scope.showMe = false; scope.toggle = function toggle() { scope.showMe = !scope.showMe; } } return { restrict : 'EA', replace : true, transclude : true, scope : scope, template : template, link : link // link : function(scope, element, attrs) {} } })

 

posted @ 2017-08-11 11:51  alan-alan  阅读(221)  评论(0编辑  收藏  举报