import {module} from '../module'; import {kebabToCamel} from '../lib/string'; /** * Registers the element controller into its scope as a * property whose name is the directive value. */ export function directive() { return { restrict: 'A', link: function($scope, $element, $attrs) { let id = kebabToCamel($attrs.vnId); let controller = $element.controller($element[0].tagName.toLowerCase()); if (!id) throw new Error(`vnId: Attribute can't be null`); if (!controller) throw new Error(`vnId: Can't find controller for element '${id}'`); $scope[id] = controller; } }; } module.directive('vnId', directive);