Skip to content

Instantly share code, notes, and snippets.

@0x-r4bbit
Created February 19, 2013 10:39
Show Gist options
  • Save 0x-r4bbit/4984760 to your computer and use it in GitHub Desktop.
Save 0x-r4bbit/4984760 to your computer and use it in GitHub Desktop.
AngularJS Zippy
'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';
}
}
}
});
<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