Sha256: c4330e0c4600483418c08800dcc0c9f544b34a92e18d515fb6c62b66c1523ef8
Contents?: true
Size: 1.07 KB
Versions: 8
Compression:
Stored size: 1.07 KB
Contents
/** * General-purpose Event binding. Bind any event not natively supported by Angular * Pass an object with keynames for events to ui-event * Allows $event object and $params object to be passed * * @example <input ui-event="{ focus : 'counter++', blur : 'someCallback()' }"> * @example <input ui-event="{ myCustomEvent : 'myEventHandler($event, $params)'}"> * * @param ui-event {string|object literal} The event to bind to as a string or a hash of events with their callbacks */ angular.module('ui.directives').directive('uiEvent', ['$parse', function ($parse) { return function (scope, elm, attrs) { var events = scope.$eval(attrs.uiEvent); angular.forEach(events, function (uiEvent, eventName) { var fn = $parse(uiEvent); elm.bind(eventName, function (evt) { var params = Array.prototype.slice.call(arguments); //Take out first paramater (event object); params = params.splice(1); scope.$apply(function () { fn(scope, {$event: evt, $params: params}); }); }); }); }; }]);
Version data entries
8 entries across 8 versions & 1 rubygems