Last active
November 19, 2015 09:55
-
-
Save schleim/de3fc79cbbd0ae6dbd1b to your computer and use it in GitHub Desktop.
Revisions
-
schleim revised this gist
Nov 19, 2015 . No changes.There are no files selected for viewing
-
schleim revised this gist
Nov 19, 2015 . No changes.There are no files selected for viewing
-
schleim revised this gist
Nov 19, 2015 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -8,3 +8,4 @@ <img ng-if="showImage" src=""> </dd> </dl> </section> -
schleim revised this gist
Nov 19, 2015 . No changes.There are no files selected for viewing
-
schleim created this gist
Nov 19, 2015 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,10 @@ <section class="accordion" accordion accordion-on-open="showImage=true" > <dl> <dt> <a href="" class="">Link</a> </dt> <dd class="cf "> Content <img ng-if="showImage" src=""> </dd> </dl> This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,27 @@ myAngularApp.directive('accordion', function() { return { restrict: 'AE', scope:{ accordionOnOpen: '&' // write attribute to scope variable }, link: function(scope, element, attrs, controller) { var $link = $(element).find('dt a'); var $pane = $(element).find('dd'); $(element).off('click').on('click',function(){ if(!$link.hasClass('active')){ $pane.slideDown(); $link.addClass('active'); scope.$apply(function() { scope.$eval(scope.accordionOnOpen); // compile attribute expression }); }else{ $pane.slideUp(); $link.removeClass('active'); } }); } }; } );