cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - Activehtmlicon-personicon-teamoctocatspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

Quick-add: + add another resource

Code Indentation

     

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

            
              <div ng-app="app" ng-controller="mainController">
  <h3>$scope.hasOwnProperty('myEvent'): {{ showEvent() }}</h3>
  <button custom-click="showEventType(myEvent)">Show myEvent.type</button>
</div>
            
          
!
            
              var app = angular.module('app', []);

app.controller('mainController', function ($scope) {
  $scope.showEvent = function () {
    return $scope.hasOwnProperty('myEvent');
  };
  $scope.showEventType = function (e) {
    alert(e.type);
  };
});

app.directive('customClick', function () {
  return {
    // Restrict this directive to attributes only.
    restrict: 'A',
    // Whatever is passed to the "ng-click" attribute is an angular expression
    // and that expression will be stored on our isolate scope as "expression".
    scope: {
      expression: '&customClick'
    },
    link: function (scope, element) {
      // "element" is the jQuery representation of the DOM element that was clicked.
      // We can simply call .on('click' just like we would in jQuery.
      element.on('click', function (e) {
        // Because this handler can be invoked at any time outside the Angular digest
        // loop, we need to tell Angular to track the logic about to happen so we call
        // scope.$apply.
        scope.$apply(function() {
          // Invoke our "expression" as a method. This triggers Angular to evaluate the
          // expression that was passed in. Also pass a hash with any variables this
          // directive has access to that the user of the directive might need to use
          // within the expression. In this case, define a variable called "$event" and
          // set it to the jQuery event that we received on click, "e".
          scope.expression({ myEvent: e });
        });
      });
    }
  };
});
            
          
!
999px
Close

Asset uploading is a PRO feature.

As a PRO member, you can drag-and-drop upload files here to use as resources. Images, Libraries, JSON data... anything you want. You can even edit them anytime, like any other code on CodePen.

Go PRO

Loading ..................

Console