Created
February 19, 2013 10:39
-
-
Save 0x-r4bbit/4984760 to your computer and use it in GitHub Desktop.
AngularJS Zippy
This file contains 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 characters
'use strict'; | |
myApp.directive('zippy', function(){ | |
return { | |
restrict: 'E', | |
transclude: true, | |
scope: { title:'@title' }, | |
template: | |
'<div class="zippy {{state}}">' + | |
'<div class="title" ng-click="toggle()">{{title}}</div>' + | |
'<div class="body" ng-transclude></div>' + | |
'</div>', | |
link: function(scope, element, attrs) { | |
scope.state = "opened"; | |
scope.toggle = function() { | |
scope.state = scope.state == 'opened' ? 'closed' : 'opened'; | |
} | |
} | |
} | |
}); |
This file contains 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 characters
<zippy title="Zippy Title"> | |
Hello there! | |
</zippy> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment